3

My Android developer and I are having trouble posting the JSON data to our drupal services. I am not familiar with Java but I have used Httpposter to post my JSON data to create nodes on my site. We are trying to accomplish this with JAVA but his multidimensional arrays aren't ending up like we need them. Has anyone had experience with Java and Drupal services posting a Drupal node from an android device. Any help would be greatly appreciated. Here is a sample of the JSON that needs sent to the server from our Android app.

    {
    "title":"Services added sale with image fix # 2",
    "type":"add_free_sale",
    "body":{
      "und":[{
        "value":"This is the body field"
            }]},
    "field_address":{
      "und":[{
        "country":"US",
        "thoroughfare":"711 B Ave W",
        "locality":"Oskaloosa",
        "administrative_area":"IA",
        "postal_code":52577
            }]},
    "field_dates":{
      "und":[{
        "value":{"date":"10/17/2012"},
        "value2":{"date":"10/17/2012"}
            }]},
    "field_sale_type":{
      "und":"Garage Sale"},
    "name":"bot",
    "language":"und",
    "date":"2012-10-20",
    "field_image":{"und":[null]}
    }

This works with Httpposter so i know services is working fine.

closed as too broad by kiamlaluno Aug 31 '17 at 21:27

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Can you also post how the JSON is currently getting through to Drupal? – Eduard Luca Nov 2 '12 at 2:04
  • I have experiance in android and drupal development but I don't get the point what your problem is... – rekire Nov 3 '12 at 20:07
  • If your Drupal service is working fine using HTTP Poster, then there may not be issue from Drupal side. Problem may lie with the way you are calling a Drupal service from Java. Anyway, you need to post more about what error you are getting. What do you mean by "his multidimensional arrays aren't ending up like we need them" ? How are they ending up? Is there an encoding issue when sending data? Posting relevant Java code might be helpful in answering this question. – Ajinkya Kulkarni Nov 4 '12 at 17:02
0

Here I am sharing the example for JSON format of drupal 7 services, here I am using POST method to register/create a user.

Endpoint URL : http://localhost/project/api/user/register Method : POST. Request Header : Content-Type/application/json. Body :

{
"name" : "your_username",
"mail" : "email_id@example.com",
"pass" :"password",
"field_first_name": {"und": [{"value": "Rahul"}]},
"field_last_name": {"und": [{"value": "Sankrit"}]},
"field_gender":{"und":"male"},
"field_custom_entity_reference": { "und": [ "2" ] },
"field_date_of_birth":{"und":[{"value":{"date":"06-14-1989"}}]},
"field_mobile_number": {"und": [{"value": "99XXXXXX12"}]}
}

Thanks

Not the answer you're looking for? Browse other questions tagged or ask your own question.