Hi,
Since direct communication with M3CE APIs is being closed in September, I am now changing existing code to use ION API instead.
I have looked at the ION API SDK on Github and have successfully executed the M3 ExportMI using GET, but when trying to execute multiple transactions in one call using POST it return status code 415 with message "Unsupported Media Type".
Does anyone know what media type to use or if it at all is possible to use the M3 bulk API via ION?
Any input is highly appreciated.
Thanks.
Rene`
-------------------------------------------------
This is my sample code based on the Infor.OAuth2SampleConsoleResourceOwner sample project.
static void CallServicePost(string token)
{
var client = new HttpClient
{
BaseAddress = new Uri(IONAPIBaseUrl)
};
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
string json = "{" +
" "program": "MRS001MI"," +
" "divi": ""," +
" "dateFormat": "YMD8"," +
" "readTimeoutMillis": 30000," +
" "excludeEmptyValues": true," +
" "rightTrim": true," +
" "maxReturnedRecords": 30," +
" "transactions": [" +
" {" +
" "transaction": "LstFields"," +
" "selectedColumns": [" +
" "FLNM"," +
" "FLDS"" +
" ]," +
" "record": {" +
" "MINM": "MRS001MI"," +
" "TRNM": "LstPrograms"," +
" "TRTP": "O"" +
" }" +
" }," +
" {" +
" "transaction": "LstTransactions"," +
" "record": {" +
" "MINM": "MRS001MI"" +
" }," +
" "selectedColumns": [" +
" "TRNM"," +
" "TRDS"" +
" ]" +
" }" +
" ]" +
"}";
var content = new StringContent(json, Encoding.UTF8, "application/json");
client.SetBearerToken(token);
var response = client.PostAsync("/ESPERSEN_TRN/M3/m3api-rest/execute", content).Result;
if (response.IsSuccessStatusCode)
{
"
WebSerivce call response.".ConsoleGreen();
}
else
{
"
WebService failed".ConsoleRed();
}
Console.WriteLine(response);
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
This is the output I get when executing:
WebService failed
StatusCode: 415, ReasonPhrase: 'Unsupported Media Type', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
}