使用 json 参数卷曲 GET 请求 [英] Curl GET request with json parameter

查看:34
本文介绍了使用 json 参数卷曲 GET 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试发送一个GET"通过 cURL 从命令提示符请求远程 REST API,如下所示:

I am trying to send a "GET" request to a remote REST API from Command Prompt via cURL like this:

curl -X GET 
  -H "Content-type: application/json" 
  -H "Accept: application/json" 
  "http://server:5050/a/c/getName/{"param0":"pradeep"}"

但它没有返回任何输出.我尝试直接从浏览器ping URL,我能够成功获得响应,我不明白该命令有什么问题.

But it returns no output. I tried to ping the URL directly from the browser, I am able to get response successfully, I don't understand what is the wrong with the command.

基本上我想设置一个GET"对远程 REST 服务的请求,该服务通过 curl 为我提供 json 数据作为响应.谁能指导我我在做什么错误?我尝试了各种帖子,但所有帖子都在讨论 POST 请求,而不是 GET.

Basically I want to set a "GET" request to a remote REST service which gives me json data as a response via curl. Can anyone guide me what mistake am I doing? I tried various posts, but all of them talk about POST requests not about GET.

推荐答案

这应该有效:

  curl -i -H "Accept: application/json" 'server:5050/a/c/getName{"param0":"pradeep"}'

使用选项 -i 而不是 x.

use option -i instead of x.

这篇关于使用 json 参数卷曲 GET 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆