I have declared the content-type however I am still getting this message:"Header missing: please add content-type: application/json or application/ejson to specify payload data types" in the error log.
Hi Shum,
Please check ContentType Parameter value, you are passing text/plain and API required application/json.
Thanks
Vinod
Hi vinod,
I have passed the content-type as application/json via site properties (Site.ContentType)
snippet from site properties:
Hi.
I can only see the action you are calling and that is fine. But the error is on the API call, not on OutSystems.
You need to set the headers here, on the method:
Is that section ok?
Hi
I have declared the content type inside the method and assigned it using site properties (in my previous reply)
Considering we don't know what API you are calling, it can be case sensitive or something unexpected.
I would try it in Postman and when it works, copy the exact configuration/format into the OS method.
I am actually calling mongodb atlas data api to update a document in the database (https://www.mongodb.com/docs/atlas/api/data-api-resources/#update-a-single-document).
I have consumed the api to read items from mongodb (and there were no issues ) but when i use the api to update items, it throws me the header error even though i have declared it. I have tested it in postman and it works fine.
The headers that correspond to the documentation seem to match. Are the others needed?
Doesn't make sense that it works on Postman and the same here doesn't.
I tried to remove the additional headers , but it's still throwing me the same error.
Hi @Shum Chin Ning,
As Nuno said you are passing the parameter to server action but it's not properly mapped with the Rest Consume Method.
Am not sure what occurs this exactly. But most of the time passing a string value might not be enclosed with quotes. Put debugger on OnBeforeRequest and check. If the issue is with the quotation adding like below will resolve it.
if possible, could you share the OML so we can help to resolve it quickly