ERP API
Integrate any ERP with the mobile applications by sending and receiving sync packets
get
https://api.portal.dynamicsmobile.com
/erp/push/:appArea/:mobileUser
Push Sync Packet
Example - NodeJs
Example - C# (RestSharp)
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.portal.dynamicsmobile.com/mobile/erp/push/DMDEV01/user1?packetUniqueId=xyz-abc-01&size=32123&packetType=xml',
'headers': {
'x-api-key': '12321313'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
const xmlResponse = response.body;
//parse reponse and obtain the value if the uploadPath field.
//use it to upload the packet content via PUT request
});
var appArea = "MyAppArea";
var apiKey = "myApiKey";
var userName = "user1"
var packetSize= 12345;
var packetFormat = "xml";
var packetId = DateTime.Now().format(mobileUser+'yyMMddhhmmss');
var client = new RestClient("https://api.portal.dynamicsmobile.com/mobile/erp/push/"+appArea +"/"+userName+"?packetUniqueId="+packetId+"&size="+packetSize+"&packetType="+packetFormat);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", apiKey);
IRestResponse response = client.Execute(request);
XmlDocument doc = new XmlDocument();
doc.LoadXml(response.Content);
//parse reponse and obtain the value if the uploadPath field.
//use it to upload the packet content via PUT request
get
https://
api.portal.dynamicsmobile.com/erp/pull/:appArea
Pull Sync Packet
Example - NodeJs
Example - C# (RestSharp)
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.portal.dynamicsmobile.com/mobile/erp/pull/DMDEV01?packetType=packet&format=xml',
'headers': {
'x-api-key': '12321313'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
const xml = response.body;
//parse the xml and iterate over the returned list of packets
});
var contentFormat = "xml";
var appArea = "MyAppArea";
var apiKey = "12345678";
var client = new RestClient("https://api.portal.dynamicsmobile.com/mobile/erp/pull/"+appArea+"?format="+contentFormat);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", apiKey);
IRestResponse response = client.Execute(request);
XmlDocument doc = new XmlDocument()
doc.LoadXml(response.Content)
//process the list
Example - NodeJs
Example - C# (RestSharp)
const appArea = "MyAppArea";
const apiKey = "123456789";
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.portal.dynamicsmobile.com/mobile/erp/pull/'+appArea+'/link?path=push_done/MYAPPAREA/2020010101/user1/xyz-abv-d011.xml',
'headers': {
'x-api-key': apiKey
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
const downloadUrl = response.body;
//execute another get request to the url returned in downloadUrl...
//the downloaded content is a Synchronization Packet Format
});
var appArea = "MyAppArea";
var apiKey = "123456789";
//packetInternalUrl is actually conained in the url field for each packetin the pending packet list
//recevied via call to the Pull Sync Packet API
//here it is provided as variable to simplify the example
var packetInternalUrl = "push_done/MYAPPAREA/2020010101/user1/xyz-abv-d011.xml";
var client = new RestClient("https://api.portal.dynamicsmobile.com/mobile/erp/pull/"+appArea+"/link?path="+packetInternalUrl );
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", apiKey);
IRestResponse response = client.Execute(request);
var temporaryDownloadLink - response.Content;
//execute another get request to the url returned in downloadUrl....
post
https://api.portal.dynamicsmobile.com
/erp/pull/:appArea/done
Packet Status Done
Example - NodeJs
Example - C#(RestSharp)
const contentFormat = "xml";
const apiKey = "123456";
const packetsToMarkAsCompleted =
`<messages>
<message><id>asdasdasd1</id><receiptHandle>abvabc1</receiptHandle>,
<message><id>asdasdasd2</id><receiptHandle>abvabc2</receiptHandle>
<message><id>asdasdasd3</id><receiptHandle>abvabc3</receiptHandle>
<messages>
`
,var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.portal.dynamicsmobile.com/mobile/erp/pull/'+appArea+'/done?format='+contentFormat,
'headers': {
'x-api-key': apiKey
}
'Content-Type': 'application/'+contentFormat
body: packetsToMarkAsCompleted
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
var contentFormat = "xml";
var apiKey = "123456";
var packetsToMarkAsCompleted = "<messages>"+
"<message><id>asdasdasd1</id><receiptHandle>abvabc1</receiptHandle>"+
"<message><id>asdasdasd2</id><receiptHandle>abvabc2</receiptHandle>"+
"<message><id>asdasdasd3</id><receiptHandle>abvabc3</receiptHandle>"+
"<messages>";
var client = new RestClient("https://api.portal.dynamicsmobile.com/mobile/erp/pull/"+appArea+"/done?format="+contentFormat);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key",apiKey);
request.AddHeader("Content-Type", "text/plain");
request.AddParameter("application/"+contentFormat, packetsToMarkAsCompleted, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);