-2

I have a webAPI that i need to call from java sever side code and get the response coming from the service .. Here is my webAPI URL..

http://pnrbuddy.com/api/check_pnr/pnr/2156641988/format/json/pbapikey/6b17f33e25e2d8197462d1c6bcb0b130/pbapisign/bd0aea241e88c8a22692eba02887ad97a220f827

This is a responsive URL ..You can check the values on typing on the Browser URL.The response of the datatype can be either xml or json.

How do I call this webAPI from android?

Bob Gilmore
  • 12,608
  • 13
  • 46
  • 53
Siddhu
  • 53
  • 1
  • 10
  • *I have a webAPI that i need to call from java sever side code* -- did you mean from the Android client side code? – Joffrey Apr 30 '14 at 14:01
  • 1
    What is your problem exactly? To execute HTTP requests from android, you can take a look at this post: http://stackoverflow.com/questions/3505930/make-an-http-request-with-android – Joffrey Apr 30 '14 at 14:04
  • @Joffrey I have a button in my android app and on button click i want to call that WebAPI... – Siddhu Apr 30 '14 at 14:05
  • @Joffrey That URL is responsive u can type that in Browser and see the response – Siddhu Apr 30 '14 at 14:06
  • And what would I do with the response? I'm asking about your question. What is it you don't manage to do? Executing an HTTP request? Reading the result? Also, you have a '…' character in your URL, I'm not sure the "HMAC SIGNATURE MISMATCH" I get is the right response... – Joffrey Apr 30 '14 at 14:07
  • @Joffrey Sorry sir..How can i call this URL from android button click event ..This is my question.I am sorry for last time .. – Siddhu Apr 30 '14 at 14:09
  • 1
    To "call an URL", you have to send an HTTP request. To see how to do it, follow the link I provided in my second comment: http://stackoverflow.com/questions/3505930/make-an-http-request-with-android – Joffrey Apr 30 '14 at 14:10
  • @Joffrey I updated the post to correct the API URL ,please see it..If you please provide me a hint with pseudo code in my case,it would be very helpfull for me,i am novice developer who is trying to grasp the things.. – Siddhu Apr 30 '14 at 14:12
  • 1
    i don't understand the question. I don't actually see a question. – njzk2 Apr 30 '14 at 14:12
  • @Siddhu, you seem to have included your API keys in your question. I suggest you change the keys and/or remove the question to protect that. – 323go Apr 30 '14 at 14:40

2 Answers2

0

My favorite way of doing it is using a helper library called RestTemplate. You can find a guide on how to do it in under 15 minutes here: http://spring.io/guides/gs/consuming-rest-android/.

It even shows you how to make a model that represents your json and have jackson deserialize your json into a java object for you.

FriendlyMikhail
  • 2,857
  • 23
  • 39
0

This forum is here to help with specific programming problems, but people usually won't write a big chunk of business code for you.

However, we can give you hints:

  • to "call a Webservice API", you'll need to execute some HTTP requests.
    You can find how to do so in this post, using Android's HttpClient.

  • your server's response is in the JSON format.
    Once you get a String out of your response, you can use the org.json API to parse it.

Community
  • 1
  • 1
Joffrey
  • 32,348
  • 6
  • 68
  • 100
  • Downvoter, would you please care to comment? This way I could improve my answer if something is incorrect or missing. – Joffrey Apr 30 '14 at 14:30
  • It wasn't me that downvoted but there are some people on Meta that believe that answering bad questions is bad for the site. I'm not one of them though. – CurlyPaul Apr 30 '14 at 14:35
  • @CurlyPaul OK, I understand. Well it's not as if I provided a full answer to a too broad question, I merely give directions for the OP to keep on searching. – Joffrey Apr 30 '14 at 14:39
  • I would agree, being helpful to new members is the right way tp go imo as well – CurlyPaul Apr 30 '14 at 14:41