I can post input data using postman where as if I use the following code it's throwing an I/O error while reading the input message: nested exception is java.net.SocketTimeoutException(400)
$http({
method: "POST",
url: '/user',
headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
data: updateEmp
}).success(function (response) {
refresh();
}).error(function (response) {
alert(JSON.stringify(response));
//alert("There some problem while fetching.");
});
Related
I have an API that expects a JWT token.
I tested the API with https://hoppscotch.io, here is the query that returns the expected results (no error)
import axios from "axios";
const options = {
method: 'POST',
url: 'https://my_authority/text-message',
headers: {
Authorization: 'Bearer my_token',
'content-type': 'application/json'
},
data: {message: ''}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
And here is the code in Dart that fires the error ClientException (Failed to parse header value):
await http.post(
Uri.parse('$_httpEndpoint/$path'),
headers: {
HttpHeaders.contentTypeHeader: 'application/json',
HttpHeaders.authorizationHeader: 'Bearer my_token',
},
body: jsonEncode(body));
Both queries have the same parameters. I have no clue about the root causes.
Here is requests.headers in locals for IOClient.send when the error fires:
_CompactLinkedCustomHashMap ({content-type: application/json; charset=utf-8, authorization: Bearer my_token})
I don't know why http adds charset=utf-8, and I didn't manage to remove it.
I looked over the internet and didn't find an answer. Most of the similar questions are related to an error in the backend, it is not the case here.
I am trying to fetch data using dbx.getThumbnailsBatch:
const response = await fetch(`https://content.dropboxapi.com/2/files/get_thumbnail_batch`, {
mode: 'no-cors',
method: "POST", // *GET, POST, PUT, DELETE, etc.
headers: {
"Authorization": "Bearer <REDACTED>",
"data": `{\"entries\":[{\"path\":\"${JSON.stringify(folders)}\"}]}`,
"Content-Type": "application/json"
},
});
const json = await response.json();
console.log(json)
And I'm getting these errors:
POST https://content.dropboxapi.com/2/files/get_thumbnail_batch 400 (Bad Request)
Uncaught (in promise) SyntaxError: Unexpected end of input (at App.js:73:1)
at nextImgs (App.js:73:1)
Can anyone tell why is this happening?
I am trying to create a sharepoint list using REST call. But i am getting error message: 'The server responded with a status of 400.'
Below is my code. Not able to understand where I am doing mistake:
url: https://abcTest.sharepoint.com/sites/dev/_api/web/lists.
digest: I am getting from a different function call.
const response = await fetch(url, {
method: 'POST',
credentials: 'include',
headers: {
'Accept': 'application/json;odata=verbose',
'Content-Type': 'application/json;odata=nometadata',
'X-RequestDigest': digest
},
body: JSON.stringify({
__metadata: {
type: 'SP.List`
},
AllowContentTyes: true,
BaseTemplate: 100,
ContentTypesEnabled: true,
Description: 'List description',
Title: 'MyList'
})
});
I think you should change
Accept: 'application/json;odata=verbose'
===> 'Accept': 'application/json;odata=verbose'
And : method: 'POST'` ===> method: 'POST'
Make sure parameter is json data.
I'm sending a message via enterprise messaging in SAP from Fiori. SAPui5 code as below.
$.ajax({
type: "POST",
url: '/messagingrest/v1/topics/SeasonalityTopic/messages',
headers: {
'Access-Control-Allow-Origin': '*',
'Authorization': 'Bearer ' + accessToken, // has a value for accessToken
'Accept': '*/*',
'Cache-Control': 'no-cache',
'x-qos': '1'
},
data: "hi",
dataType: "json",
contentType: "application/x-www-form-urlencoded",
beforeSend: function (xhr) {
// xhr.setRequestHeader('Authorization', bearer);
},
success: function (ret) {
var aa = 1;
},
error: function (err) {
var aa = 2;
}
});
But this returns below message.
{ "message": "x-qos is invalid" }
the x-qos is a required header parameter, the possible values are 0 or 1.
Per what I discovered reading some of the documentation:
0: Does not require a confirmation to remove the message from the queue.
1: Does require a confirmation message to confirm delivery and to remove it from the queue.
Some useful documentation:
https://help.sap.com/doc/3dfdf81b17b744ea921ce7ad464d1bd7/Cloud/en-US/messagingrest-api-spec.html
https://blogs.sap.com/2019/08/19/sap-enterprise-messaging-and-sap-cloud-platform-integration-pubsub-pattern/
see the bellow sample code which i am trying to send it to the server
var serializedData = $.param({
api: key,
user: $scope.user.username
});
$http({
method: 'POST',
url: URL+"login_master/login",
data: serializedData,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}})....