2017-03-03 43 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創建狀態