以下代码发送 GET 请求。这让我发疯。
let postDocRaw (url:string) (data: string) : string =
let data' : byte[] = System.Text.Encoding.ASCII.GetBytes(data);
let request = WebRequest.Create(url)
request.Method <- "POST"
request.ContentType <- "application/x-www-form-urlencoded"
request.ContentLength <- (int64) data'.Length
use wstream = request.GetRequestStream()
wstream.Write(data',0, (data'.Length))
wstream.Flush()
wstream.Close()
(*
use writer = new StreamWriter (wstream)
writer.Write(data')
writer.Flush()
writer.Close()
*)
let response = request.GetResponse()
use reader = new StreamReader(response.GetResponseStream())
let output = reader.ReadToEnd()
reader.Close()
response.Close()
request.Abort()
output
Run Code Online (Sandbox Code Playgroud)
目前我不确定是否有人曾经使用 F# 发送 HTTP POST。有没有人看过这方面的文档?
我正在尝试用 PHP 构建一个 Web 应用程序。
但我不想使用 GET 和 POST 方法,因为用户应该知道我们发送数据的内容和方式,只需查看 html 端即可。当然,我们可以随时清理数据,但我仍然想保留数据的格式。
有没有上面的替代方案...
可以用 url 做些什么,这样就不会显示数据的类型和格式。我在这方面看到了一些与 mod 重写相关的东西。
请建议并告诉我我是否在正确的轨道上。
我正在制作一个 chrome 扩展,我有一个 popup.html 页面,其中包含一个带有方法帖子的表单,当使用弹出按钮打开时它不会做任何事情但是如果页面作为选项页面或只是一个普通的 html 页面打开,表单发布正常,新页面已加载。
所以弹出窗口中的某些内容阻止了表单工作。
我不知道为什么,有人知道如何解决/解决这个问题吗?
您将如何使用相同的键发送具有多个值的请求?
r = requests.post('http://www.httpbin.org/post', data={1: [2, 3]})
print r.content
Run Code Online (Sandbox Code Playgroud)
{
...
“形式”: {
“1”:“3”
},
...
}
编辑:
嗯,很奇怪。我尝试使用一个简单的 Flask 应用程序回显发布数据,我得到:
[('1', u'2'), ('1', u'3')]
Run Code Online (Sandbox Code Playgroud)
这只是httpbin.org的一个缺点吗?
我正在使用 ownCloud(开源云),并且我有一个表单来上传文件,该表单将发布请求发送到处理上传的 upload.php 文件。请求有很多字段,需要发送所有信息和 cookie。
我需要开发 ac# 代码来将文件上传到云端。在我看来,最好的方法是提出一个类似于表单请求的请求。你怎么看?有什么建议?
ps 我阅读了以下解决方案,但它不起作用。 在 c# 中使用 HTTP POST 发送文件 http://bytes.com/topic/c-sharp/answers/268661-how-upload-file-via-c-code 使用 HTTPWebrequest (multipart/form-data) 上传文件
谢谢
这是一些代码:
表格:
<form data-upload-id='1'
id="data-upload-form"
class="file_upload_form"
action="<?php print_unescaped(OCP\Util::linkTo('files', 'ajax/upload.php')); ?>"
method="post"
enctype="multipart/form-data"
target="file_upload_target_1">
<input type="hidden" name="MAX_FILE_SIZE" id="max_upload" value="<?php p($_['uploadMaxFilesize']) ?>">
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" id="requesttoken">
<input type="hidden" class="max_human_file_size" value="(max <?php p($_['uploadMaxHumanFilesize']); ?>)">
<input type="hidden" name="dir" value="<?php p($_['dir']) ?>" id="dir">
<input type="file" id="file_upload_start" name='files[]'/>
<a href="#" class="svg"></a>
</form>
Run Code Online (Sandbox Code Playgroud)
这是我看到的请求的方式:
enter code here
Request URL:http://my-url/owncloud/index.php/apps/files/ajax/upload.php
Request Method:POST
Status …Run Code Online (Sandbox Code Playgroud) 我想使用“表单数据”发送 HTTP Post 请求。这是 rest-client 的屏幕截图,以显示我想要什么:

与标题相关的更多信息:
POST /action HTTP/1.1
Host: requsrt-utl
Cache-Control: no-cache
----WebKitFormBoundaryE19zNvXGzXaLvS5C
Content-Disposition: form-data; name="email"
abc@gmail.com
----WebKitFormBoundaryE19zNvXGzXaLvS5C
Content-Disposition: form-data; name="password"
123456
----WebKitFormBoundaryE19zNvXGzXaLvS5C
Run Code Online (Sandbox Code Playgroud)
我尝试使用UrlEncodedFormEntity但它将内容类型设置为“application/x-www-form-urlencoded”,这是不正确的。
我的安卓代码:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(urlStr);
try {
UrlEncodedFormEntity encodedFormEntity = new UrlEncodedFormEntity(nameValuePairs);
httppost.setEntity(encodedFormEntity);
HttpResponse httpresponse = httpclient.execute(httppost);
return httpresponse.getEntity().getContent();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
当我使用它时,网络服务没有得到任何参数,因此它发送一条消息“参数不存在”。
请帮忙!
我需要使用HttpPost方法上传带有多个参数的图像和视频文件,如文件名,描述,高度和宽度.
谢谢,建议赞赏.
我正在使用Cloud Code和Express,托管在Parse上传图像.
这是Parse日志中的错误:
I2015-01-03T13:35:55.199Z] TypeError: Cannot read property 'thumbnail' of undefined
at app.js:40:25
at callbacks (express_router.js:161:37)
at param (express_router.js:135:11)
at pass (express_router.js:142:5)
at Router._dispatch (express_router.js:170:5)
at Object.router (express_router.js:33:10)
at next (connect_proto.js:240:15)
at Object.expressInit [as handle] (express_middleware.js:31:5)
at next (connect_proto.js:240:15)
at Object.query [as handle] (connect_query.js:44:5)
Run Code Online (Sandbox Code Playgroud)
似乎Express JS/Parse无法理解req.files.XXX.在以下行的app.js中出现错误:console.error(req.files.thumbnail.size);
此外,req.files打印以下错误:未提供消息
这是recipecontent.ejs代码:
<!DOCTYPE html>
<html>
<form method="post" enctype="multipart/form-data" action="/saverecipecontent">
Enter Recipe Image 1:
<input type="file" name="thumbnail" id="thumbnail">
<input type="submit">
</form>
</html>Run Code Online (Sandbox Code Playgroud)
这是app.js代码:
// These two lines are required to initialize Express in Cloud Code. …Run Code Online (Sandbox Code Playgroud)javascript forms http-post image-uploading express parse-platform
我在班级和汽车班之间有一对多的关系.一个人可以拥有许多汽车,反之亦然.我正在使用restful API发布数据.我的注释和获取服务工作正常但我的帖子服务抛出"java.sql.SQLIntegrityConstraintViolationException:ORA-01400:无法插入NULL"错误,每当我尝试插入新数据.子表外键正在插入为null.
这是我的代码的一部分.
Person.java
private List<Car> cars = new ArrayList<Car>();
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="person")
@JsonManagedReference
public List<Car> getCars() {
return cars;
}
Run Code Online (Sandbox Code Playgroud)
Car.java
private Person person;
@ManyToOne
@JoinColumn(name = "PERSON_ID", nullable = false, updatable = true, insertable = true)
@JsonBackReference
public Person getPerson() {
return person;
}
Run Code Online (Sandbox Code Playgroud)
我的服务类:
@POST
@Path("/PersonRegistration")
@Consumes(MediaType.APPLICATION_JSON)
public Response postPersonCars(Person person) throws Exception{
Session session = null;
ObjectMapper mapper = new ObjectMapper();
//Person per = new Person();
//Car cars = new Car();
try{
session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction(); …Run Code Online (Sandbox Code Playgroud) 标头:授权:承载YOUR_CLIENT_ACCESS_TOKEN
如何使用上述代码在Google Dialogflow中发出HTTP请求?我如何添加标头作为HTTP请求的一部分