带有json参数的Curl GET请求 [英] Curl GET request with json parameter

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

问题描述

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

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网址,我能够获得响应成功,我不明白该命令是什么错误。

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数据作为响应。任何人都可以指导我做什么错误?我尝试了各种帖子,但是所有人都谈论的不是GET的POST请求。

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.

推荐答案



This should work :

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

用户选项-i而不是x。

user option -i instead of x.

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

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