Ich versuche, eine Transaktion auf Platz mit Uni-Rest mit Knoten zu buchen. Ich glaube, dass ich alle erforderlichen Parameter habe, wie auch immer ich einen 422 Fehler zurück vom Quadrat erhalte, in den Beschreibungen, die es sagt, Körper in Körper erforderlich. Wird einige Codebeispiele und Fehler unten veröffentlichen.422 Fehler beim Versuch, Transaktion zu buchen
Meine Anfrage:
var json = {
"idempotency_key": "74ae1696-b1e3-4328-af6d-f1e04d947a13",
"shipping_address": {
"address_line_1": "123 Main St",
"locality": "San Francisco",
"administrative_district_level_1": "CA",
"postal_code": "94114",
"country": "US"
},
"billing_address": {
"address_line_1": "500 Electric Ave",
"address_line_2": "Suite 600",
"administrative_district_level_1": "NY",
"locality": "New York",
"postal_code": "10003",
"country": "US"
},
"amount_money": {
"amount": 5000,
"currency": "USD"
},
"card_nonce": "CBASEA-NYZAdKADzd5FeF6kh0ko", //sandbox nonce
"reference_id": "some optional reference id",
"note": "some optional note",
"delay_capture": false
}
//console.log(json)
return unirest.post('http://connect.squareup.com/v2/locations/9T8KRNF0XX6BH/transactions')
.headers({'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization' : 'Bearer '+access_token, 'rejectUnauthorized': false})
.type('json')
.send(json)
.end(function (json) {
if(json.error){
console.log(json.error);
}
console.log(json.body)
res.json(json)
});
}
Mein Fehler:
{ Error: got 422 response
at /Users/.../node_modules/unirest/index.js:395:27
at process._tickCallback (internal/process/next_tick.js:98:9) status: 422 }
{ errors: [ { category: 'INVALID_REQUEST_ERROR',
code: 'BAD_REQUEST',
detail: 'body in body is required' } ] }
Vielen Dank !! etwas so Kleines verursachte mir so viel Kummer. –