我试图创建一个新的Square用户,但有问题。我能够使用Unirest在https://connect.squareup.com/v2/customers
端点上获得Square客户列表,但还未能成功发布。
const unirest = require('unirest');
const access_token = 'sq-123...';
var createCustomer =
unirest.post('https://connect.squareup.com/v2/customers')
.headers({
"Accept": "application/json",
"Authorization": "Bearer " + access_token})
.send({
"email_address": "abc@example.com"
})
.end(function (createCustomer) {
console.log(createCustomer);
});
响应返回
raw_body:
'{"errors":[{
"category":"INVALID_REQUEST_ERROR",
"code":"BAD_REQUEST",
"detail":"invalid character \'e\' looking for beginning of value (line 1, character 1)"}]}' }
我还尝试使用.field
而不是.send
,后者返回
raw_body: '{"errors":
[{"category":"INVALID_REQUEST_ERROR",
"code":"BAD_REQUEST",
"detail":"invalid character \'-\' in numeric literal (line 1, character 2)"}]}' }
是否可以使用Unirest和Node创建客户?如果是的话,我哪里出错了?
发布于 2017-04-18 10:30:13
以下代码将发布
const unirest = require('unirest');
const access_token = 'sq-123...';
var createCustomer =
unirest.post('https://connect.squareup.com/v2/customers')
.headers({
"Content-Type": "application/json",
"Authorization": "Bearer " + access_token})
.send({
"email_address": "abc@example.com"
})
.end(function (createCustomer) {
console.log(createCustomer);
});
https://stackoverflow.com/questions/43461953
复制相似问题