Hello i have a task to create a client that can remotely add entries to blog. By doing this i need to call HTTP POST and put proper content to forms ( at least i guess so)
blog
HTML Code:
url is:someblog.com/blog.jsp?action=new
html of a servlet that is responsible to manually add entries:
HTML Code:
<form class="MultiFile-intercepted" enctype="multipart/form-data" method="post" onsubmit="return checkAnomalyFields();" action="dodajN.html">
<table style="border-weight: 0px">
<tbody>
<tr>
<tr>
<td id="wybory">
<select id="typ" onchange="typeSelected()" size="1" name="typuId">
</td>
<td>
</tr>
<tr>
<tr>
<td colspan="2">
<textarea cols="60" rows="10" name="opis">Opis nieprawidłowości</textarea>
</td>
</tr>
<tr> </tr>
<tr>
<td>
<div id="fileDiv">
<div id="MultiFile1_wrap" class="MultiFile-wrap">
<input class="multi MultiFile-applied" type="file" maxlength="5" accept="jpg" name="undefined" value="">
<div id="MultiFile1_wrap_list" class="MultiFile-list"></div>
</div>
</div>
</td>
</tr>
to make a request i use:
HttpClient httpclient = new MyHttpClient(Send.this);
HttpPost httppost = new HttpPost("https://blog.com/blog.jsp?action=new");
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
nameValuePairs.add(new BasicNameValuePair("typuId", "Wysypisko"));
nameValuePairs.add(new BasicNameValuePair("statusuId", "Do moderacji"));
nameValuePairs.add(new BasicNameValuePair("os", "android"));
nameValuePairs.add(new BasicNameValuePair("szer", "52.321911"));
nameValuePairs.add(new BasicNameValuePair("dlug", "19.464111000000003"));
nameValuePairs.add(new BasicNameValuePair("opis", "jakis opis"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
HttpEntity responseEntity1 = response.getEntity();
String responseEntityString = EntityUtils.toString(responseEntity1);
but insteed of submitting the request i got HTML of website as response, it looks like i dont try to make an entry but to read site content only. Any idea what i am doing wrong?