【问题标题】:Postman: How to execute Paypal CURL Request in Postman?Postman:如何在 Postman 中执行 Paypal CURL 请求?
【发布时间】:2017-07-23 01:17:42
【问题描述】:

我能够获得 oAuth 请求和响应

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

但是当我运行它时总是给出 401 Unauthorized

在Postman下面如何执行?

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"
      }
    }
  ]
}'

【问题讨论】:

    标签: php curl paypal postman


    【解决方案1】:

    首先需要将数据部分粘贴到Body中:

    {"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"
    
        }
        }]
    
    }
    

    然后,您必须选择 raw 并在 Text 下选择 JSON(application/json)

    授权部分,进入Headers:

    [key:Content-Type, value:application/json]
    [key:Authorization, value:Bearer YOUR_TOKEN]
    

    然后点击发送,您应该会得到 201 Created 状态

    【讨论】:

      【解决方案2】:

      看来你有两个问题:

      1:您必须获取访问令牌

      作为 sais 文档:

      这就是你得到 401 Unauthorized 的原因,你必须配置授权类型 OAuth2,并使用你的访问令牌:

      2:我在邮递员上制作了这个 curl 示例的图形示例。

      标题:

      正文:

      授权:不要忘记像第一个问题一样配置令牌。

      就是这样!

      【讨论】:

        【解决方案3】:

        从上图中,您似乎没有以 JSON 格式发送数据。在 paypal 示例中,它显示了数据的 JSON 对象 (-d)。您所要做的就是将其复制并粘贴到正文并将正文更改为原始,然后在最后一列上它会显示文本和一个箭头,只需单击它并选择 JSON (application/json) 这应该可以。

        【讨论】:

        • 尝试包含代码行并格式化您的问题,使其清晰易读。
        • @Masoud 我认为你需要对他的问题发表评论让他看到。
        • “问题”是一个错字。我的意思是你的答案。
        • @Masoud 答案是配置而不是任何代码。我不知道如何发布图片,但他所要做的就是更改该配置。
        猜你喜欢
        • 2019-11-25
        • 2018-01-30
        • 1970-01-01
        • 2017-09-08
        • 2020-03-04
        • 1970-01-01
        • 1970-01-01
        • 2020-08-19
        • 2019-07-05
        相关资源
        最近更新 更多