Woocommerce REST API Postman 的响应正确,不在 Xcode
Woo-Commerce REST API response correct on Postman not in Xcode
我正在实施 "POST" api 通过 woo-commerce 创建订单:
POST http://www.url.in/wp-json/wc/v1/orders
我也在为它使用外部库 Oauth1,它使用单腿身份验证。现在,当我在 Postman 上 运行 API 时,它给了我正确的响应,但在代码中它给了我错误:
{
"code":"woocommerce_rest_cannot_create",
"message":"Sorry, you are not allowed to create resources.",
"data":{"status":401}
}
在我的代码中,我正在创建一个 NSDictionary ,我通过 NSJSONSerialization 将其更改为 NSData 并将其作为 HTTPBody 与请求一起发送。
查看随附的 Postman 屏幕截图和 Xcode。
[
问题出在我正在 posting 的 JSON 数据中。而不是posting NSDictionary,我不得不post它作为NSString。在那之后它就像一个魅力。
我正在实施 "POST" api 通过 woo-commerce 创建订单:
POST http://www.url.in/wp-json/wc/v1/orders
我也在为它使用外部库 Oauth1,它使用单腿身份验证。现在,当我在 Postman 上 运行 API 时,它给了我正确的响应,但在代码中它给了我错误:
{
"code":"woocommerce_rest_cannot_create",
"message":"Sorry, you are not allowed to create resources.",
"data":{"status":401}
}
在我的代码中,我正在创建一个 NSDictionary ,我通过 NSJSONSerialization 将其更改为 NSData 并将其作为 HTTPBody 与请求一起发送。
查看随附的 Postman 屏幕截图和 Xcode。
[
问题出在我正在 posting 的 JSON 数据中。而不是posting NSDictionary,我不得不post它作为NSString。在那之后它就像一个魅力。