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?
We are unable to change the content-type of the APIs as they are used within the product and in other integrations too. Is there any other work-around for this purpose?
@ManiDeepak_Vandrangi Sorry for the delay in response, as mentioned previously, documentation for “application/rdsConnectComputer.v1+json” is not available as it is a self customized Media Type that resembles a JSON (hence +json). It is used as a part of a Jersey API in the annotations. We have multiple other similar content types that are used for multiple APIs
We rarely support specific response types. Apps can bypass this restriction by using third party npm libraries to send HTTP/HTTPS requests. Are you facing any problems by using third party npm library?
Hey @ManiDeepak_Vandrangi , As discussed, I am able to use axios to initiate an API request from my app’s web client to our development server.
But in the App Guidelines it is mentioned that we should use only the Request API to perform any kind of external API calls. Doesn’t using axios override this security point?
Also while using axios I am able to see the request originates from *.cloudfront.net. Unfortunately we wouldn’t be able to allow CORS for any cloudfront domains. Kindly advise on the same.
@sanjay.sr - I see you are trying to make API calls from frontend of the app. In that case, even the API calls made from ‘axios’ would fail as Browsers themselves block CORS. Which is why an client.request API is available for the apps to make requests from the frontend.
Now if client.request doesn’t support the requested the content type, we will need to see if there is a possibility to support application/rdsConnectComputer.v1+json. This might not be possible, but I could check from the team for an update.
That leaves the app to anyway rely on an NPM package to make the API call. This is possible using Server Method Invocation and NPM Packages. Nevertheless, the requests that your server would receive by using an NPM package would be from a dynamic IP. API calls from the backend can also be made by a equivalent variant of Request Method by
$request.get("URL", options)
.then(
function(data) {
//handle "data"
//"data" is a json string with status, headers, and response.
},
function(error) {
//handle failure
}
);
API calls made from using Request Method would originate from specific IP ranges that you can whitelist. In your case requires external NPM package in backend to make the API call.
Edit 1: Note that SMI may have size restrictions upto 100kb