简体   繁体   English

如何将参数传递给Post URL C#

[英]How to pass parameter to Post URL C#

My code : 我的代码:

  string postData = "'Country+Code':'US'&'Start+Date':'2018-01-01'&'End+Date':'2018-07-02'";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
request.Headers["Authorization"] = "Bearer " + accessToken;
var response = (HttpWebResponse)request.GetResponse();

I am getting 404 not found error : 我收到404 not found错误:

I guess problem in Post data so i tride : 我想邮政数据中的问题,所以我部落:

//string postData = "'Country Code':'US'&'Start Date':'2018-01-01'&'End Date':'2018-07-02'";
// string postData = "Country Code:'US':1&Start Date:'2018-01-01'&End Date:'2018-07-02'";

But still got error : 404 not found , finding correct way ? 但是仍然出现错误:找不到404,找到正确的方法?

If http status you receiving as 404 (Method Not Found), there are several possibilities for such error : 如果您收到的HTTP状态为404(找不到方法),则可能会出现这种错误:

  1. Ensure service hosted 确保托管服务
  2. Url Incorrect 网址错误
  3. If in case url correct then the ensure the service host as POST method. 如果url正确,则确保服务主机为POST方法。 If its hosted as PUT & if you are calling it as POST then you may receive such error. 如果将其托管为PUT&如果将其称为POST,则可能会收到此类错误。
  4. If all above case you have verified , cross verify whether you are sending the expected input data as per contract. 如果以上所有情况均已通过验证,请交叉验证您是否按照合同发送了预期的输入数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM