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-
$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 !
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.