This is my data object -
这是我的数据对象 -
var bill = {
"type":"insert",
"args": {
"table": "finance_data",
"objects": [
{
"title": $scope.data.title,
"url": $scope.data.url,
"type":"payments"
}
]
}
};
This is my config object-
这是我的配置对象 -
var config = {
headers:{
'Authorization' : "Bearer "+ $localStorage.auth_token,
}
};
I'm doing a POST request to my server to insert data into a table ( db: PostgreSQL) This is my http request code-
我正在向我的服务器发送POST请求以将数据插入表中(db:PostgreSQL)这是我的http请求代码 -
$http.post('https://data.saarang.org/v1/query', bill, config).then(function(response){
console.log('success');
alert('Successfully uploaded the Payment Receipt!');
$state.reload();
}).catch(function(err){
console.log(err);
});
Object { data: Object, status: 400, headers: headersGetter/<(), config: Object, statusText: "Bad Request" }
The err.data object has an error message - 'invalid JSON' The bill object has all the fields that are required but still the server throws back an "invalid JSON" error Please Help !
err.data对象有一条错误消息 - “无效的JSON”bill对象具有所需的所有字段,但服务器仍然会返回“无效的JSON”错误请帮助!
1 个解决方案
#1
0
I found the solution myself, it wasn't any backend/server related issue, the url key in the object was supposed to be Url. The typo caused an invalid JSON error.
我自己找到了解决方案,它不是任何与后端/服务器相关的问题,对象中的url键应该是Url。拼写错误导致无效的JSON错误。
#1
0
I found the solution myself, it wasn't any backend/server related issue, the url key in the object was supposed to be Url. The typo caused an invalid JSON error.
我自己找到了解决方案,它不是任何与后端/服务器相关的问题,对象中的url键应该是Url。拼写错误导致无效的JSON错误。