这是我的数据对象 -
var bill = {
"type":"insert",
"args": {
"table": "finance_data",
"objects": [
{
"title": $scope.data.title,
"url": $scope.data.url,
"type":"payments"
}
]
}
};

这是我的配置对象 -
var config = {
headers:{
'Authorization' : "Bearer "+ $localStorage.auth_token,
}
};

我正在向我的服务器发送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" }
&#13;
err.data对象有一条错误消息 - &#39;无效的JSON&#39; bill对象具有所需的所有字段,但服务器仍然会返回一个&#34;无效的JSON&#34;错误 请帮忙 !
答案 0 :(得分:0)
我自己找到了解决方案,它没有任何与后端/服务器相关的问题,对象中的 url 键应该是 Url 。错字导致无效的JSON错误。