POST:在网址中发送帖子请求 [英] POST: sending a post request in a url itself

查看:356
本文介绍了POST:在网址中发送帖子请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了一个网址.. www.abc.com/details 并要求使用在此网址上发送我的姓名和电话号码POST 。他们告诉我使用以下键将content-type设置为application / json,将body设置为有效的JSON:

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 发送相同的内容吗?

or do i have to use java to send the same?

请帮助

推荐答案

基于根据你提供的内容,你需要做的事情非常简单,你甚至可以通过多种方式去做。你需要的东西可以让你根据你的要求发布一个正文。几乎所有编程语言都可以执行此操作以及命令行工具(如cURL)。

Based on what you provided, it is pretty simple for what you need to do and you even have a number of ways to go about doing it. You'll need something that'll let you post a body with your request. Almost any programming language can do this as well as command line tools like cURL.

您已经确定了工具,您需要创建JSON主体并提交它到服务器。

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

使用cURL的一个例子是(所有在一行中,减去 \ 在第一行结束):

An example using cURL would be (all in one line, minus the \ at the end of the first line):

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

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

The above command will create a request that should look like the following:

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

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

这篇关于POST:在网址中发送帖子请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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