Hi,
I would like to create a new user via REST server with module Services 3.x
For the user it is mandatory to specify birthday date.
I'm sending the data as JSon:
{..., "field_fecha_nacimiento":{"und":[{"value":"Sun May 19 12:56:15 CEST 1970"}]}, ...}
Values for drupal field_fecha_nacimiento are of unix timestamp type.
I'm trying with time in millis as integer, millis as string, I tried 12/05/1980, 05/12/1980, 1980-05-12, 1980/05/12, always getting the same response:
Error 406.
Not Acceptable: The value input for field Fecha de nacimiento is invalid
How should I send a date field to a REST server in JSON format?
Comments
Comment #0.0
miqmago commentedAdding details of the data I am sending to the server
Comment #1
jjemmett commentedSending this request to the correct project.
Comment #2
jjemmett commentedI am also having a problem with uploading values to CCK date fields. Please let us know how best to do this.
Comment #3
miqmago commentedI don't really know why you changed the version. In fact I use 7.x version and have this problem...
Workaround for me worked:
Send data {... "timezone":"Europe/Andorra","fecha_nacimiento":13131231..., ...}
fecha_nacimiento as long Timestamp in seconds.
In the server:
Comment #4
miqmago commentedTake care on updating the received timestamp to the server timezone.. otw you get wrong times (not a problem with birth dates, could be worst in other cases)
Comment #5
ygerasimov commentedYou need to send date values how they are passed in the form. See http://drupal.org/node/1662912#comment-6193900
Comment #6.0
(not verified) commentedAdded field type in server
Comment #7
jagermonster commentedOk well since no one actually added an example of this i decided to add an example of the array to be posted
Comment #8
prempatel2447 commentedComment #9
rahul_sankrit commentedHi All,
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