I have been given a url .. www.abc.com/details and asked to send my name and phone number on this url using POST. They have told me to set the content-type as application/json and the body as valid JSON with the following keys:

name: name of the user
phone number: phone number of the user

Now i have no clue how to send this request! Will it be something like:

http://www.abc.com/details?method=post&name=john&phonenumber=445566

还是我必须用java来发送同样的信息?

请帮忙

推荐答案

根据你提供的信息,你需要做的事情非常简单,你甚至有很多方法go 做.你需要一些东西,可以让你发布一个带有你的请求的正文.几乎任何编程语言都能做到这一点,就像cURL这样的命令行工具一样.

One you have your tool decided, you'll need to create your JSON body and submit it to the server.

使用cURL的示例如下(全部在一行中,减go 第一行末尾的\):

curl -v -H "Content-Type: application/json" -X POST \
     -d '{"name":"your name","phonenumber":"111-111"}' http://www.abc.com/details

上述命令将创建一个如下所示的请求:

POST /details HTTP/1.1
Host: www.abc.com
Content-Type: application/json
Content-Length: 44

{"name":"your name","phonenumber":"111-111"}

Json相关问答推荐

无法根据vega规范中的条件设置文本 colored颜色

Jolt转换问题—使用键查找匹配对象

PowerShell脚本-替换json数组(转义$var将被视为不带双引号的文本)

如何在PowerShell中访问嵌套的JSON字段

Flutter -控制器问题-JSON API

JSON API返回多个数组,需要帮助拼合数据以存储在SQL Server数据库表中

将部分数据字节解组到自定义 struct 中

如何避免解析 ISuperObject 类型字段中的 json 对象

使用 jq 获取所有嵌套键和值

如何从条带订阅响应对象中正确获取 struct 项?

jq:用列表包装所有第一级原子值

如何使用 Serde 使用顶级数组反序列化 JSON?

JSON RPC - 什么是id?

一起使用 Argparse 和 Json

使用 @ResponseBody 自定义 HttpMessageConverter 来做 Json 事情

如何使用 C# 将 JSON 文本转换为对象

如何在 Perl 中将简单的哈希转换为 json?

如何在 swift 2 中获取 Alamofire.request().responseJSON 的结果值?

如何将 Swift 对象转换为字典

MVC JsonResult camelCase 序列化