标签: http-post

通过URL发送POST请求

有一个asp页面,我进入我的Rollno并按提交,下一页显示我的结果.以下是页面的形式来源.

<form name="form1" method="post" action="Result.asp">

   <input name="Rollno" type="text" id="RollNo" size="15" maxlength="15">

   <input type="submit" name="Submit" value=" Search " onClick="return num();">

</form>
Run Code Online (Sandbox Code Playgroud)

没有办法看到所有学生的结果,因此我想循环遍历所有的滚动数字以查看我的位置.但我无法通过编写search.asp来做到这一点?Rollno = 123456

如何通过URL发送请求,以便我可以遍历所有数字?

parsing http http-post html-parsing

3
推荐指数
1
解决办法
1万
查看次数

如何通过curl发送REST XML POST请求?

基本上,我在Restlet中设置了一个项目,它使用JAXRS将资源映射到路径,并使用JAXB将XML序列化和反序列化为Java类型.我正在尝试发送POST请求以测试它是否有效,而且我遇到了一些麻烦.这是我的资源:

@Path("stream")
public class StreamResource {

    @POST
    @Consumes("text/xml")
    @Produces("text/xml")
    public Stream save(Stream value) {
        logger.debug("saving new stream...");
        return (Stream)this.streamPersistence.save(value);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的Stream班级:

@XmlRootElement(name="stream")
@XmlType(propOrder={"id", "streamName", "title", "description", fileSystemPath"})
public class Stream {

    private Long id;

    private String streamName;

    private String fileSystemPath;

    private String title;

    private String description;

    // getters/setters omitted for brevity
}
Run Code Online (Sandbox Code Playgroud)

以下是我的调用方式curl:

curl -X POST -d '<stream><streamName>helloWorld.flv</streamName><title>Amazing Stuff, Dude!</title><description>This stream is awesome-cool.</description><fileSystemPath>/home/rfkrocktk/Desktop/helloWorld.flv</fileSystemPath></stream>' --header 'Content-Type:"text/xml"' http://localhost:8888/stream
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误curl:

The given resource variant is not …
Run Code Online (Sandbox Code Playgroud)

rest curl http jaxb http-post

3
推荐指数
1
解决办法
9262
查看次数

在HTTPResponse Android中重定向之后

我需要遵循HTTPost给我的重定向.当我创建一个HTTPost,并尝试读取响应时,我得到重定向的页面html.我怎样才能解决这个问题?码:

public void parseDoc() {
    final HttpParams params = new BasicHttpParams();
    HttpClientParams.setRedirecting(params, true);
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(
            "https://secure.groupfusion.net/processlogin.php");
    String HTML = "";
    try {
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
        nameValuePairs.add(new BasicNameValuePair("referral_page",
                "/modules/gradebook/ui/gradebook.phtml?type=student_view"));
        nameValuePairs.add(new BasicNameValuePair("currDomain",
                "beardenhs.knoxschools.org"));
        nameValuePairs.add(new BasicNameValuePair("username", username
                .getText().toString()));
        nameValuePairs.add(new BasicNameValuePair("password", password
                .getText().toString()));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        String g = httppost.getURI().toString();

        HttpResponse response = httpclient.execute(httppost);

        HTML = EntityUtils.toString(response.getEntity());
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String ResponseBody = httpclient.execute(httppost, responseHandler);
        sting.setText(HTML);

    } catch (ClientProtocolException e) {
    } catch …
Run Code Online (Sandbox Code Playgroud)

java android http-post

3
推荐指数
1
解决办法
5474
查看次数

带边界的C#HTTP POST

我需要一点帮助在C#中设置HTTP Post.我感谢您提前获得的任何帮助.

在这里使用Fiddler是我的RAW POST:

POST http://www.domain.com/tester.aspx HTTP/1.1
User-Agent: Tegan
Content-Type: multipart/form-data; boundary=myboundary
Host: www.domain.com
Content-Length: 1538
Expect: 100-continue


<some-xml>

        <customer>
                <user-id>george</user-id>
                <first-name>George</first-name>
                <last-name>Jones</last-name>
        </customer>

</some-xml>
Run Code Online (Sandbox Code Playgroud)

我的要求有点棘手.他们需要一个带有边界的多部分职位.我不熟悉设置边界.如果任何人可以提供帮助我会很感激.

这是我的要求:

POST http://www.domain.com/tester.aspx HTTP/1.0(CRLF)
User-Agent: myprogramname(CRLF)
Content-Type: multipart/form-data; boundary=myboundary(CRLF)
Content-Length: nnn(CRLF)
(CRLF)
(CRLF)
--myboundary(CRLF)
Content-Disposition: form-data; name=”xmlrequest”(CRLF)
Content-Type: text/xml(CRLF)
(CRLF)
(XML request message)(CRLF)
(CRLF)
--myboundary--(CRLF)
Run Code Online (Sandbox Code Playgroud)

所以我认为这应该是POST应该是什么样子但我需要一些帮助我的C#.

POST http://www.domain.com/tester.aspx HTTP/1.1
User-Agent: Tegan
Content-Type: multipart/form-data; boundary=myboundary
Content-Length: 1538

--myboundary
Content-Disposition: form-data; name="xmlrequest"
Content-Type: text/xml

<some-xml>

            <customer>
                    <user-id>george</user-id>
                    <first-name>George</first-name>
                    <last-name>Jones</last-name>
            </customer>

    </some-xml>

(CRLF)
--myboundary--
Run Code Online (Sandbox Code Playgroud)

这是我用来创建WebRequest的C#代码.

HttpWebRequest request …
Run Code Online (Sandbox Code Playgroud)

c# http-post httpwebrequest

3
推荐指数
1
解决办法
6807
查看次数

$ _POST无法正常工作."注意:未定义的索引:用户名..."

可能重复:
PHP:"注意:未定义的变量"和"通知:未定义的索引"

所以,我目前正在学习PHP并正在阅读一本关于密码的md5函数的书,所以我决定尝试一下,看看它是怎么回事.我还决定使用POST方法而不是GET,因为我看到人们说它更安全,并且不会让变量出现在URL上.

对于我的测试项目,我做了一个非常简单的表格,如下:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form action="dologin" method="POST">
            <table border="0">
                <tbody>
                    <tr>
                        <td>Username:</td>
                        <td><input type="text" name="username"></td>
                    </tr>
                    <tr>
                        <td>Password:</td>
                        <td><input type="password" name="password"></td>
                    </tr>
                </tbody>
            </table>
            <input type="submit" value="Login">
        </form>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

问题是当我在BOTH字段中输入值并单击"Login"时,我在另一个PHP文件上得到以下输出.

Notice: Undefined index: username in C:\xampp\htdocs\md5\home\dologin\index.php on line 11
Username non existent
Run Code Online (Sandbox Code Playgroud)

以下是"/dologin/index.php"文件的代码

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php
            mysql_connect("localhost", "root") or die(mysql_error());
            mysql_select_db("test") or die(mysql_error());
            $query = "SELECT password FROM users …
Run Code Online (Sandbox Code Playgroud)

php http-post undefined-index

3
推荐指数
1
解决办法
9万
查看次数

在post请求中将JSON传输到服务器

服务器有两个参数:String和JSON.提示,正确我JSON在POST请求中传输和字符串?

try {
    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost("my_url");
    List parameters = new ArrayList(2);
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("par_1", "1");
    jsonObject.put("par_2", "2");
    jsonObject.put("par_3", "3");
    parameters.add(new BasicNameValuePair("action", "par_action"));
    parameters.add(new BasicNameValuePair("data", jsonObject.toString()));
    httpPost.setEntity(new UrlEncodedFormEntity(parameters));
    HttpResponse httpResponse = httpClient.execute(httpPost);
    Log.v("Server Application", EntityUtils.toString(httpResponse.getEntity())+" "+jsonObject.toString());

} catch (UnsupportedEncodingException e) {
    Log.e("Server Application", "Error: " + e);
} catch (ClientProtocolException e) {
    Log.e("Server Application", "Error: " + e);
} catch (IOException e) {
    Log.e("Server Application", …
Run Code Online (Sandbox Code Playgroud)

post android json http-post

3
推荐指数
1
解决办法
1万
查看次数

在POST操作中更改ViewModel属性

我有这个POST动作:

[HttpPost]
public ActionResult GetReport(GetReportModel model)
{
    if (!ModelState.IsValid)
    {
        return View(model);
    }

    return View("GetReport", new GetReportModel()
       { 
          Identifier = "test", 
          Permission = true 
       });
}
Run Code Online (Sandbox Code Playgroud)

当我发布表单时,执行此操作后,生成的视图中没有任何更改.我的意思是,TextBoxfor Identifier没有我在动作中设置的"test"字符串值.但如果我清除ModelState,View将显示新值:

[HttpPost]
public ActionResult GetReport(GetReportModel model)
{
    if (!ModelState.IsValid)
    {
        return View();
    }

    ModelState.Remove("Identifier");
    ModelState.Remove("Permission");

    return View("GetReport", new GetReportModel() 
       {
          Identifier = "test", 
          Permission = true 
       });
}
Run Code Online (Sandbox Code Playgroud)

我不明白为什么会这样?如果模型状态无效,为什么每个人都将模型返回到View?例如,Microsoft的默认项目模板具有以下代码:

public ActionResult Login(LoginModel model, string returnUrl)
{
    if (ModelState.IsValid)
    {
        return RedirectToLocal(returnUrl);
    }
    // Why do they pass the …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc http-post

3
推荐指数
1
解决办法
1045
查看次数

服务器端的大型机身POST请求为空

当POST我向Play框架操作方法发出一个具有大型主体的请求null时,我会在提取数据时得到.如果身体相当小,我可以很好地检索数据.

这是一个示例短数据集:

{
  "creator": "zoltan",
  "sport": "hike",
  "geometry": [
    {
      "time": "2009-07-10 12:56:10 +0000",
      "x": 10.275514,
      "y": 47.514749,
      "z": 756.587
    },
    {
      "time": "2009-07-10 12:56:19 +0000",
      "x": 10.275563,
      "y": 47.514797,
      "z": 757.417
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

当我POST在正文中发出使用此JSON 的请求时,一切正常.但是,如果我在geometry数组中添加更多(~4000)个点,我就会null参与其中.

这是我的行动方法:

@Transactional
//@BodyParser.Of(Json.class) // tried with this as well
public static Result createTour() {
    LOG.debug("Raw request body: " + request().body().asText());
    JsonNode node = request().body().asJson();
    LOG.debug("JSON request body: " + node);
    TourDto tourDto;
    try …
Run Code Online (Sandbox Code Playgroud)

json http-post http-content-length playframework playframework-2.2

3
推荐指数
1
解决办法
1932
查看次数

HTTP POST方法返回状态代码404

当我通过以下方法执行API时,我总是得到404作为响应代码.

private void execute() throws IllegalStateException, IOException, NoSuchAlgorithmException {

    Map<String, String> comment = new HashMap<String, String>();
    comment.put("accounts-groups", "customers/enterprise");
    comment.put("companyType", "customer");
    comment.put("companyName", "Test");
    String json = new GsonBuilder().create().toJson(comment, Map.class);
    Log.i(TAG, "json : "+json);

    HttpResponse response = makeRequest(URL, json);

    /*Checking response */
    if(response != null) {
        InputStream inputStream = response.getEntity().getContent(); //Get the data in the entity
        int statusCode = response.getStatusLine().getStatusCode();
        Log.i(TAG, "statusCode : "+statusCode);
        String result;
        // convert inputstream to string
        if(inputStream != null)
            result = convertStreamToString(inputStream);
        else
            result = "Did not …
Run Code Online (Sandbox Code Playgroud)

java android http-post

3
推荐指数
1
解决办法
3万
查看次数

Spring MVC @RequestParam一个对象列表

我想创建一个页面,其中一个人看到一个用户列表,并且每个人旁边都有一个复选框,该人可以单击以删除它们.

在我使用REST API的MVC中,我想将一个User对象列表发送到REST API.

在可@RequestParam注解支持?

例如:

@RequestMapping(method = RequestMethod.DELETE, value = "/delete")
    public @ResponseBody Integer delete(
            @RequestParam("users") List<Users> list) {
        Integer deleteCount = 0;
        for (User u : list) {
            if (u != null) {
                repo.delete(u);
                ++deleteCount;
            }
        }
        return deleteCount;
    }
Run Code Online (Sandbox Code Playgroud)

在MVC客户端中,URL将是:

List list = new ArrayList<User>();
....
String url = "http://restapi/delete?users=" + list;
Run Code Online (Sandbox Code Playgroud)

rest spring spring-mvc http-post httprequest

3
推荐指数
2
解决办法
2万
查看次数