Fast-android-networking: Calling twilio api doesnt work? It returns only com.androidnetworking.error.ANError

Created on 20 May 2017  路  27Comments  路  Source: amitshekhariitbhu/Fast-Android-Networking

question

Most helpful comment

Yep it works. Thanks very much. I can see my fault.

All 27 comments

https://{Account_SID}:{Token}@api.twilio.com/2010-04-01/Accounts/{Acount_SID}/SMS/Messages.json
It is working fine with POSTMAN. But i am not able to get response with this networking library.
How can fix it?

can you tell me the exact code? That will help me to serve you better.

Yes here is my code.

JSONObject param = new JSONObject();
try {
param.put("From", fromNo);
param.put("To", toNo);
param.put("Body", getString(R.string.receiveSMS) + verifyNumber);
} catch (JSONException e) {
e.printStackTrace();
}

AndroidNetworking.post("https://" + getString(R.string.twilio_account_sid) + ":" + getString(R.string.twilio_token) + "@api.twilio.com/2010-04-01/Accounts/" + getString(R.string.twilio_account_sid) + "/SMS/Messages.json")
.addJSONObjectBody(param)
.build()
.getAsJSONObject(new JSONObjectRequestListener() {
@Override
public void onResponse(JSONObject response) {
Log.d("logs", "Response : " + response.toString());
}

                                @Override
                                public void onError(ANError anError) {
                                    Log.d("logs", "Error : " + anError.toString());
                                }
                            });

well twilio token number and account sid is correct. It's working fine with POSTMAN

what error you are getting -> anError.toString()

com.androidnetworking.error.ANError

error.getDetail()?

responseFromServerError

check for error.getErrorBody() and errorCode

{"code": 20003, "detail": "Your AccountSid or AuthToken was incorrect.", "message": "Authentication Error - No credentials provided", "more_info": "https://www.twilio.com/docs/errors/20003", "status": 401} 401

Oh i am using the same url with postman. but it works fine.

You can use pathParamter also. Refer link

there may be case that the URL is not building correctly. Check for that.

same issue with using pathParameter.
and URL is correct. I've checked several times and copy the link and paste it in postman.

The request is get or post?

post

What information do you need? Plz tell me exactly.

Account SID, Token number, From phone no. Do you need these informations?

only the things required in URL

Just sent detailed informations to your gmail

Checking

Ok thanks

I have mailed you the solution

Oh let me see. Just mins

Yep it works. Thanks very much. I can see my fault.

can you please send me that code .I am facing the same issue.

screenshot_20180110-164719
@ayushdimri

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GulajavaMinistudio picture GulajavaMinistudio  路  3Comments

alitong picture alitong  路  8Comments

anderscheow picture anderscheow  路  5Comments

AymanAbouzeid picture AymanAbouzeid  路  4Comments

Patrick-Wallin picture Patrick-Wallin  路  8Comments