0

I have created API for creating a customer in PHP, the client side is in Android would use a POST request to access this API. For testing I have used chrome postman where I had used post data as :

{"name":"test","marks":["12","13","16"],"age":19}

and it is working fine.

I am getting marks as array itself ["12","13","16"].

But from android client I am getting as text ["12","13","14"].

What may be the possible reason?

Irfan DANISH
  • 8,349
  • 12
  • 42
  • 67
PRASANTH
  • 695
  • 3
  • 15
  • 33
  • @PRASANTH Im not sure I have understood your doubt properly; but from your post, what I feel is that, you have confusion on the JSON data available in Android client, Im I right? You want to get the response in the form of a JSON object. – rahul Nov 11 '13 at 06:11
  • @rahul exactly no problem for web but there may be some problem with content type. – PRASANTH Nov 11 '13 at 06:18
  • @PRASANTH you mean, you are not getting a proper json response in the Android side? If it works on the Postman, Im sure there is some trouble with the codes in the client side. Can you post that here? – rahul Nov 11 '13 at 06:23
  • @PRASANTH try this http://stackoverflow.com/questions/3408985/json-array-iteration-in-android-java – rahul Nov 11 '13 at 08:12

2 Answers2

0

POST it as :

{"name":"test","marks":[12,13,16],"age":19}

You are posting it as String inside array ["12","13","16"]

Vicky Gonsalves
  • 11,593
  • 2
  • 37
  • 58
0

try to use it like

{"name":"test","marks":["12","13","16"],"age":19}
Harish Singh
  • 3,359
  • 5
  • 24
  • 39