1

正如您可以查看下面的屏幕截图,我尝试在 Contentful 中进行 PUT api 调用以更新条目。

当我尝试打 GET 调用时,一切正常,但在这里不明白在进行 PUT 调用时出现以下错误的原因是什么。

我在这里错过了什么或有什么不对吗?

注意:我在拨打电话时更改了所有变量、spaceId、env、entryId 和授权(传递 access_token)

使用邮递员对 Contentful 进行 api 调用

4

1 回答 1

1

From what I see in your URL, it looks like you are trying to hit the Contentful Preview API, which is read-only.

API Base URL https://preview.contentful.com This is a read-only API

source

Therefore, updating an entry via a PUT request cannot be done with the url you are using.


However, I believe your PUT request should work if you update the base url to be https://api.contentful.com/ instead. This is the endpoint for the Content Management API.

Important note:


Using https://api.contentful.com/ hits the writable Content Management API, which has documentation for the PUT request you are making.

Importing the corresponding curl command into your Postman client will confirm this.


So in the end, the url would be this:

https://api.contentful.com/spaces/{space_id}/environments/{environment_id}/entries/{entry_id}

Again, the bearer token will have to come from the writable Content Management API.

于 2021-05-10T17:57:19.947 回答