Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Problem in posting json data from android

 
Ranch Hand
Posts: 99
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have trouble posting json on a php server.

my code is -



The status code from server is 200 but when i print response stream on logcat in eclipse i am getting undefined index message for method, event_id, device_id, device_token, session_id.

Notice: Undefined index: method in /mypath/file.php on line 17

INFO/Read from Server 200(493):

INFO/Read from Server 200(493): Notice: Undefined index: event_id in /mypath/file.php on line 18

INFO/Read from Server 200(493):
..............................................
..............................................................



What I am doing wrong ? Is this is because of server side php file or something wrong in java code?

Thanks
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see what this has to do with Android. Apparently the JSON that is being posted can't be handled by that PHP page. If this was my problem I'd create a Java desktop client application that gets this right before integrating it into an Android app; it's much easier to debug that way.
 
Anuj Prashar
Ranch Hand
Posts: 99
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying....

so the 'undefined index' problem is because of php page?

 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not quite - it's because the PHP page is getting something other than what it can handle. Either the PHP code is incorrect, or the JSON is different than what the PHP code expects. We can't really speculate which one of these it is, but *you* can, since both the JSON and the PHP are under your control, and amenable to being changed by you.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic