Copy link to clipboard
Copied
I have a simple function that sends some JSON to my API.
However, when the server receives it, it says the the Content Type is invalid as it is '' (empty).
var saveAssessment = app.trustedFunction(function() {
const params = {
cVerb: "POST",
cURL: "http://localhost:8089/api/step-by-step-assessment",
oBody: assessmentJsonString,
aHeaders: {
"Content-Type": "application/json",
},
oHandler: {
response: function(msg, uri, error) {
if (error != undefined) {
app.alert("Error ocurred: " + JSON.stringify(error));
} else app.alert("Success!");
},
}
};
Net.HTTP.request(params);
});
Copy link to clipboard
Copied
The assessmentJsonString is not null, I just excluded it from the post.
I did actually find the solution, which was changing my endpoint to accept 'application/octet-stream'. Because, changing the Content-Type did not actually change it's type.
Copy link to clipboard
Copied
May be that assessmentJsonString is empty.
Copy link to clipboard
Copied
The assessmentJsonString is not null, I just excluded it from the post.
I did actually find the solution, which was changing my endpoint to accept 'application/octet-stream'. Because, changing the Content-Type did not actually change it's type.