2017-03-03 44 views
1

我能够得到的OAuth请求&响应邮差:如何在Postman中执行Paypal CURL请求?

https://developer.paypal.com/docs/integration/direct/make-your-first-call/

enter code here

但是当我运行它总是给401未授权

如何邮差下面执行?

curl -v https://api.sandbox.paypal.com/v1/payments/payment \ 
    -H "Content-Type: application/json" \ 
    -H "Authorization: Bearer Access-Token" \ 
    -d '{ 
    "intent":"sale", 
    "redirect_urls":{ 
    "return_url":"http://example.com/your_redirect_url.html", 
    "cancel_url":"http://example.com/your_cancel_url.html" 
    }, 
    "payer":{ 
    "payment_method":"paypal" 
    }, 
    "transactions":[ 
    { 
     "amount":{ 
     "total":"7.47", 
     "currency":"USD" 
     } 
    } 
    ] 
}' 

enter image description here

回答

1

从上图中就好像你不能发送数据的JSON。在paypal示例中,它显示数据的JSON对象(-d)。所有你需要做的就是将它复制并粘贴到主体上,然后将主体更改为raw,然后在最后一列显示文本和箭头,然后选择JSON(application/json),这应该这样做。

+0

尝试包含代码行和格式化问题要说清楚,并且说明问题IBLE。 – Masoud

+0

@Masoud我认为你需要评论他的问题让他看到它。 –

+0

“问题”是一个错字。我的意思是你的答案。 – Masoud

0

好像你有两个问题:

1:你必须获得令牌

为最高审计机关的文件访问:enter image description here

为什么你得到一个401未经授权这就是你必须配置授权类型OAuth2,并使用您的访问令牌:enter image description here

2:我在postman上做了这个卷曲示例的图形例子。

标题:enter image description here

身体:enter image description here

授权:作为你第一个问题后,不要忘记配置令牌。

就这样!

1

首先,你需要在主体中的数据部分粘贴:

{"intent": "sale", 
"redirect_urls": { 
    "return_url": "http://example.com/your_redirect_url.html", 
    "cancel_url": "http://example.com/your_cancel_url.html" 

}, 
"payer": { 
    "payment_method": "paypal" 

}, 
"transactions": [{ 
    "amount": { 
     "total": "7.47", 
     "currency": "USD" 

    } 
    }] 

} 

然后,你必须选择原料,并在文本选择JSON(应用/ JSON)

对于授权的一部分,去标题: [key:Content-Type,value:application/json] [key:授权,值:承载人YOUR_TOKEN] 然后点击发送,你应该得到一个201创建状态