【问题标题】:To get the response for the API using curl command using wiremock使用 curl 命令使用 wiremock 获取 API 的响应
【发布时间】:2016-05-23 18:27:23
【问题描述】:

我有以下请求和响应内容。

请求

HTTP/1.1 POST /identity/v1/users
Content‐Type: application/json
Accept: application/json
{
"firstName" : "foo", "lastName" : "bar", "email" : "test@test.com", "password" : "secret123ABC"
}

回应

HTTP/1.1 201 Created

{"id":111985014}

我试图使用 curl 命令来获取响应,但我得到了不同的错误并且不明白如何去做。如果有人知道,请提供帮助。

【问题讨论】:

    标签: curl wiremock


    【解决方案1】:

    试试这个:

    curl -XPOST http://<your-domain>/identity/v1/users -H "Content‐Type: application/json" -H "Accept: application/json" -d '{"firstName" : "foo", "lastName" : "bar", "email" : "test@test.com", "password" : "secret123ABC"}'
    

    【讨论】:

    • 我想知道它如何为您给出的答案返回响应“id”。当我尝试它时,它正在抛出 Connection denied 错误。
    • @user6348718 你把&lt;your-domain&gt;改成真实地址了吗?
    • @user6348718 看起来像 wiremock 没有运行,或者您尝试连接到错误的端口。
    • 当我运行该命令时,出现 500 错误,提示未定义内容类型,而且我的疑问是当我没有指定我想要的响应时如何获得响应?
    猜你喜欢
    • 2022-07-07
    • 1970-01-01
    • 1970-01-01
    • 2015-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多