gpt4 book ai didi

post - 如何在 Insomnia 中发送带有参数的 POST 请求?

转载 作者:行者123 更新时间:2023-12-04 13:56:55 25 4
gpt4 key购买 nike

我在 OpenAPI 中定义了以下 POST 方法:

post:
tags:
- Courses
description: Creates a new Course and add it to specified Program
parameters:
- name: Program
in: path
description: Specified Program to add the new course to
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Course'

在失眠中,我可以定义 Course对象,我想通过 body/JSON 选项卡添加,但是如何定义所需的参数?它在 Query 选项卡中的工作方式与在 GET 方法中的工作方式不同。

我是否使用参数手动设置 POST 请求的路径,或者是否有构建方式(或者根本不可能)?

这是尝试在“查询”选项卡中添加程序参数时的 curl :
curl --request POST \
--url 'http://localhost:8080/Courses?Program=Testprogram' \
--header 'content-type: application/json' \
--data '{
"name": "TestCourse",
"type": "UE",
"etcs": 26,
"courseID": 909090
}'

最佳答案

我遇到了完全相同的问题,我的问题是从 HTTP 到 HTTPs 的内部重定向 (nginx),它更改了请求类型,并且无法维护请求正文。
奇怪的是,它与“Multipart Form”一起工作。
因此,请确保在 Insomnia 中提供完整的 URI,包括用于请求的协议(protocol)。
我通过将来自 Insomnia GUI 的请求复制为 cURL 发现了这个问题。命令并将其粘贴到我的终端中,这给了我一个 301 Permanently moved . ;)

关于post - 如何在 Insomnia 中发送带有参数的 POST 请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60883573/

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