I tried to create a model for SAP AIN in a SAPUI5 Dashboard using the API. I got the response "HTTP 415 Unsupported Media Type".
var payload = {
"internalId": sModelId,
"templateId": "<ID>",
"organizationID": "<ID>",
"description": {"short": sModelId},
"equipmentTracking": "1"
};
oJson.loadData("/ain/services/api/v1/models", encodeURI(JSON.stringify(payload)), true, "POST");
oJson is a JSONMOdel. "/ain/" provides the destination to the API. How can I deliver the payload correctly. What is my mistake?
2nd question:
I did successfully use a GET request targetting "/ain/services/api/v1/models" to list all the models. But when I try to set a filter inside the query parameters, the filter won't work when there is a '+' inside the filtered manufacturer string. I did use uri encoding.
This is my code:
var sQuery = "$filter=(manufacturer eq '" + encodeURIComponent(sManu) + "')";
this._oFilteredModel.loadData("/ain/services/api/v1/models", sQuery);
sManu is a string defining the manufacturer filtered by and _oFilteredModel is a JSONModel.