0

我正在尝试使用 POST 方法(Revenue REST API),但我总是收到错误消息“Content-Type not application/json”。

The strange is that I'm using their website to test: [https://docs.revenuecat.com/reference#receipts][1]

API 测试(图像)

curl --request POST \
     --url https://api.revenuecat.com/v1/receipts \
     --header 'Accept: application/json' \
     --header 'Authorization: Bearer xxxx' \
     --header 'Content-Type: application/json' \
     --header 'X-Platform: android' \
     --data '
{
     "product_id": "xxxx",
     "price": 12.9,
     "currency": "BRL",
     "is_restore": "false",
     "app_user_id": "xxxx",
     "fetch_token": "xxxxxx"
}
'

有什么线索吗?

4

2 回答 2

0

我已经使用 CURL 运行了代码并且它可以工作。问题出在收入猫网站上。

于 2021-06-28T22:44:37.410 回答
0

他们的 API 测试页面有一个错误。Content-Type: application/json 它为请求添加了一个额外的标头。Metadata您可以在选项卡中看到它

Request Headers

Accept: application/json
Content-Type: application/json
X-Platform: stripe
Content-Type: application/json
Authorization: Bearer ********************
User-Agent: ReadMe-API-Explorer

并发送带有无效标头的请求(您可以在浏览器网络流量中检查它):

content-type: application/json, application/json
于 2021-10-28T13:35:23.210 回答