gpt4 book ai didi

json - Api 蓝图和长时间运行的作业

转载 作者:行者123 更新时间:2023-12-05 00:21:48 25 4
gpt4 key购买 nike

我想用 long running jobs 正确设计我的 json API与 Blueprint .
我需要处理文件,返回 202 Accepted带有位置标题然后设计临时位置谁将收到303 See Other然后是最终对象 201 Created .

有没有办法正确设计这个序列?

最佳答案

蓝图可能如下所示:

# Stars [/stars]

Collection of stars.

## Create [POST]
+ Request (application/json)

Create a star

+ Body

{"name": "Death Star"}

+ Response 202

Request has been accepted into the queue. Poll the queue item to check the result.

+ Headers

Location: /queue/12345


# Queue Item [/queue/{id}]

One item in a job queue.

+ Parameters
+ id: 12345 (number) - Id of the queue

## Query Status [GET]
+ Response 200 (aplication/xml)

The job is still in progress.

+ Body

<response>
<status>PENDING</status>
<eta>2 mins.</eta>
<link rel="cancel" method="delete" href="/queue/12345" />
</response>

+ Response 303

The job has finished. See the created resource.

+ Headers

Location: /stars/97865

关于json - Api 蓝图和长时间运行的作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30934031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com