Source Code and Post method
Hi,
Thanks for your contribution.
Firstly, we don't have any access to your code or you have deleted it ? I can't see any source code when I fork your project.
Secondly, I think there is a bug in your project (that's why I wanted to fork it). In case of POST Method, if you had values in "body" (.withBody("{name:popapp ,age:27}")), this is not working ! The request doesn't have the body params.
TY
thank you. i will check this ASAP!
how did find out there is no body in the request? can i see your full code?
about deletation, i dont know what do you meen, the project is rigt here https://github.com/studioidan/HttpAgent
Sent with MailTrack https://mailtrack.io/install?source=signature&lang=en&[email protected]&idSignature=22
2016-08-12 16:24 GMT+03:00 Maxime Charruel [email protected]:
Hi,
Thanks for your contribution.
Firstly, we don't have any access to your code or you have deleted it ? I can't see any source code when I fork your project.
Secondly, I think there is a bug in your project (that's why I wanted to fork it). In case of POST Method, if you had values in "body" (.withBody("{name:popapp ,age:27}")), this is not working ! The request doesn't have the body params.
TY
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/studioidan/HttpAgent/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AEugVvepvejaVrwKQsCmlkd3HA0Fw0Ehks5qfHP-gaJpZM4JjFF3 .
פיתוח אפליקציות אנדרואיד - 0524667179
You deleted all your source code in previous commit ... https://github.com/studioidan/HttpAgent/commit/83a098729659d38ec839b978cc482b666fc088b8
HttpAgent.post(baseAPIUrl + "xxx.json").headers("Authorization", tokenApp, "Content-Type","application/json", "Accept", "application/json").withBody("{email:" + email + ",password:" + password + ",salt:" + salt + "}").goJson(new JsonCallback() {@Override protected void onDone(boolean success, JSONObject jsonObject) {}});
Back from vacation, in fact this is my bad, I didn't check the API I was requesting, it required JSON Post parameters, so I get your code and updated a little to manage this case :
public HttpAgent withBody(String... bodies) { if (bodies.length % 2 != 0) { mErrorMessage += "\nbodies must be even number"; Log.e(TAG, "bodies must be even number"); return this; } for (int i = 0; i < bodies.length; i += 2) { mBodies.put(bodies[i], bodies[i + 1]); } this.mHasBody = !U.isEmpty(bodies); return this; }
if (mHasBody) { JSONObject jsonParam = new JSONObject(); for (Map.Entry<String, String> entry : mBodies.entrySet()) { jsonParam.put(entry.getKey(), entry.getValue()); } DataOutputStream printout; printout = new DataOutputStream(mConnection.getOutputStream ()); String str = jsonParam.toString(); byte[] data=str.getBytes("UTF-8"); printout.write(data); printout.flush (); printout.close (); }
HttpAgent.post(baseAPIUrl + "clients.json") .headers("Authorization", tokenApp, "Content-Type", "application/json", "Accept", "application/json") .withBody("email", email, "password", password, "salt", salt)
Maybe you can upgrade your repo to manage this JSON case. Anyway Thanks for the feedback. You should upgrade your repo anyway, there is not the source in last commit !
tnx! i'll add this functionallity! is your api server is microsoft web api?
Sent with MailTrack https://mailtrack.io/install?source=signature&lang=en&[email protected]&idSignature=22
2016-08-22 13:03 GMT+03:00 Maxime Charruel [email protected]:
Back from vacation, in fact this is my bad, I didn't check the API I was requesting, it required JSON Post parameters, so I get your code and updated a little to manage this case :
`public HttpAgent withBody(String... bodies) { if (bodies.length % 2 != 0) { mErrorMessage += "\nbodies must be even number"; Log.e(TAG, "bodies must be even number"); return this; } for (int i = 0; i < bodies.length; i += 2) { mBodies.put(bodies[i], bodies[i + 1]); }
this.mHasBody = !U.isEmpty(bodies); return this;}`
`if (mHasBody) { JSONObject jsonParam = new JSONObject();
for (Map.Entry<String, String> entry : mBodies.entrySet()) { jsonParam.put(entry.getKey(), entry.getValue()); } DataOutputStream printout; printout = new DataOutputStream(mConnection.getOutputStream ()); String str = jsonParam.toString(); byte[] data=str.getBytes("UTF-8"); printout.write(data); printout.flush (); printout.close (); }`HttpAgent.post(baseAPIUrl + "clients.json") .headers("Authorization", tokenApp, "Content-Type", "application/json", "Accept", "application/json") .withBody("email", email, "password", password, "salt", salt)
Maybe you can upgrade your repo to manage this JSON case. Anyway Thanks for the feedback. You should upgrade your repo anyway, there is not the source in last commit !
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/studioidan/HttpAgent/issues/3#issuecomment-241368079, or mute the thread https://github.com/notifications/unsubscribe-auth/AEugVq8rgEI7WVnq629FrGXNEEQl4a9aks5qiXQMgaJpZM4JjFF3 .
פיתוח אפליקציות אנדרואיד - 0524667179
No, this is just a Symfony project with FOSRestBundle, we created an API with some methods. We could have use html params but we used JSON (dunno why ;))