I'm trying to send some JSON data to an asp.net web api controller like this (from here):
JSONObject Parent = new JSONObject();
Parent.put("enterpriseId", "55e8a2a3-466d-46dc-95ce-bc5f2d3e7828");
List<Integer> lst = new ArrayList<Integer>();
lst.add(1);
lst.add(2);
lst.add(3);
lst.add(4);
lst.add(5);
Parent.put("itemids", lst);
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httpPostRequest = new HttpPost(Financial.AccountReviewUrl+"/testtesttest");
StringEntity se;
se = new StringEntity(Parent.toString());
//Set HTTP parameters
httpPostRequest.setEntity(se);
httpPostRequest.setHeader("Accept", "application/json");
httpPostRequest.setHeader("Content-type", "application/json; charset=utf-8");
httpPostRequest.setHeader("AuthenticationToken", Financial.UserEncrypt);
Log.d("json is", Parent.toString());
Log.d("use encryp is", Financial.UserEncrypt);
return httpclient.execute(httpPostRequest);
My web api action:
[HttpPost]
public Object TestTestTest(Guid enterpriseId, List<int> itemIds)
{
var count = 0;
if (itemIds != null)
count = itemIds.Count;
return enterpriseId.ToString() + ":" + count.ToString();
}
And I keep getting a 404 error. I know that this has been asked multiple times previously but none of the recommended answers seem to work for me. Any ideas?