This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Android and the fly likes Problem in posting json data from android Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Problem in posting json data from android" Watch "Problem in posting json data from android" New topic
Author

Problem in posting json data from android

Anuj Prashar
Ranch Hand

Joined: Apr 15, 2008
Posts: 99

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


SCJP 5,SCWCD 5, RHCT
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41089
    
  44
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.


Ping & DNS - my free Android networking tools app
Anuj Prashar
Ranch Hand

Joined: Apr 15, 2008
Posts: 99

Thanks for replying....

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

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41089
    
  44
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in posting json data from android
 
Similar Threads
Sending a jason object via Post
Connect to server on LAN
read php session from android
How to post data from android app to php page
Client Android JSON--- Server side PhP .....error..!!