I am using an external API in my App that sends a response with content-type application/rdsConnectComputer.v1+json
While hitting the API, I am getting the following error code:
{
"status":415,
"headers":{},
"response":"Unsupported content type",
"errorSource":"APP",
"attempts":1
}
I can confirm that the API sends data correctly. While browsing about the error I came across that only application/json
is supported by client.request
. Am I doing something wrong or is there any work-around for receiving custom content types from APIs?
Code snippet for reference:
var apiUrl = serverHome + '/api/apiEndpoint/initiate';
var headers = {
'Authorization': '<%= apikey %>',
'Content-Type' : 'application/rdsConnectComputer.v1+json',
'Accept' : 'application/rdsConnectionInfo.v1+json'
};
var bodyJson = {
'name' : 'Desktop' ,
'message' : message
};
var options = {
headers: headers,
body: JSON.stringify(bodyJson)
};
client.request.post(apiUrl, options).then(function (data) {
var jsonData = JSON.parse(data.response);
console.log(jsonDate.isSuccess);
});