【问题标题】:How to pass --data "{'myuid':'testuser1'}" while testing Rest API with the RestClient如何在使用 RestClient 测试 Rest API 时传递 --data "{'myyuid':'testuser1'}"
【发布时间】:2018-04-03 19:30:09
【问题描述】:

我正在 RestClient 中测试以下 API,但我没有收到响应,因为我不知道如何传递 --data "{'myyuid':'testuser1'}"。

curl -k -v -c cookies.txt -b cookies.txt 
     -X POST 
     -H "Content-Type:application/json" -H "Accept: application/json"
     --data "{'myuid':'testuser1'}"
     "https://<isam address>/mgaapi/sps/apiauthsvc?PolicyId=urn:ibm:security:authentication:asf:mytotp"

我也附上了截图。

我应该如何在 RestClient 中正确传递 --data "{'myyuid':'testuser1'}" 以获得服务器的响应?

RestAPI Testing

【问题讨论】:

  • 一点点适当的谷歌搜索会产生你想要的结果。 stackoverflow.com/questions/13132794/…
  • 我在请求标头中设置了 Content-Typevalue = application/json。在 Content-Type=application/json 的请求正文中传递 --data "{'myuid':'testuser1'}" 是否有任何特殊格式?
  • my.usgs.gov/confluence/display/sciencebase/… 检查这个,看看你哪里做错了。还有一件事,键值不应该用双引号而不是单引号吗?
  • 我回答了,试试看它是否有效
  • 是的,我现在已经尝试在请求正文中使用 {"myyuid":"testuser1"} 并成功收到响应。

标签: json api rest-client advanced-rest-client


【解决方案1】:

用很少的(正确和必需的)格式试试这个:

curl -k -v -c cookies.txt -b cookies.txt 
     -X POST
     -H "Content-Type:application/json" 
     -H "Accept: application/json"
     --data '{"myuid":"testuser1"}'
     https://<aa>/mgaapi/sps/apiauthsvc?PolicyId=urn:ibm:security:authentication:asf:mytotp

格式是这样的: curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' URL

【讨论】:

    猜你喜欢
    • 2017-12-02
    • 2019-05-10
    • 2016-04-17
    • 1970-01-01
    • 2020-01-17
    • 2018-10-21
    • 1970-01-01
    • 2019-10-28
    • 1970-01-01
    相关资源
    最近更新 更多