tilo
June 30, 2025, 2:17pm
1
Hi there exciting folks,
as a newbe I’m not sure, if this is the right forum.
I need to create a new member/adherent via REST. eg.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'DOLAPIKEY: xxxxxxxxx' -d '{"firstname":"Erika","lastname": "Musternann","statut":1}' 'https://test.home64.de/api/index.php/members'
but constantly getting this result:
{
"error": {
"code": 400,
"message": "Bad Request: Invalid value specified for `request_data`"
},
"debug": {
"source": "Validator.php:718 at validate stage",
"stages": {
"success": [
"get",
"route",
"negotiate",
"authenticate"
],
"failure": [
"validate",
"message"
]
}
}
}
I tried statut as well as status (and both). No Hints in the Logs.
My PHP skills are rather limited. If I check the file ./includes/restler/framework/Luracast/Restler/Data/Validator.php I find a hint that the request cannot valudate the class array<string,string>. That doesn’t get me any further. The payload must have a different structure. But how?
Has anybody an idea?
Help appreciated.
hi. Here’s how I use the API.
create some object inside Dolibarr using the GUI
get that very same object using the API
copy the json, modify it a bit and feed it back to the API
Failure? change the modification
Success? go check out the object inside Dolibarr so I understand the field relations
1 Like
tilo
July 2, 2025, 8:20pm
3
hi,
thanks for your reply.
I followed exactly what you described.
I removed the id attribute, followed by the others step by step.
The only response is
{
"error": {
"code": 400,
"message": "Bad Request: Invalid value specified for `request_data` class not exists: array<string,string> array<string,string>"
},
"debug": {
"source": "Validator.php:720 at validate stage",
"stages": {
"success": [
"get",
"route",
"negotiate",
"authenticate"
],
"failure": [
"validate",
"message"
]
}
}
}
Hey, I just remembered that I was hit by something similar
opened 01:34PM - 22 Apr 25 UTC
closed 10:25PM - 23 May 25 UTC
I get a HTTP 400 error when sending a POST to `/members` on the REST API. The sa… me API call was working with v20, no longer with v21. And I have not yet identified if it's an error of the client side or Dolibarr side (Dolibarr REST API).
```bash
POST to /members failed with HTTP error 400: {
"error": {
"code": 400,
"message": "Bad Request: Invalid value specified for `request_data`"
},
"debug": {
"source": "Validator.php:718 at validate stage",
"stages": {
"success": [
"get",
"route",
"negotiate",
"authenticate"
],
"failure": [
"validate",
"message"
]
}
}
}
```
This is coming from the Restler data validator here:
https://github.com/Dolibarr/dolibarr/blob/99b1bcf4d0b2ffeca80eec697ac14578673b3c6a/htdocs/includes/restler/framework/Luracast/Restler/Data/Validator.php#L718
I initially though that I had to change the datatype of one of my payload fields, but since the error applies to `request_data` instead of one of my own payload fields, I wonder if the problem could be deeper than that?
The problem is NOT that I'm sending an empty payload. Because the latter usually causes error "Bad Request: morphy field missing", which is not the case here.
So the payload is found but something else is wrong.
Is "message" supposed to be null here under?
Here is the content of `$info` in `Validator.php`:
```
{
"value": null,
"label": "Request Data",
"field": null,
"default": null,
"name": "request_data",
"required": false,
"from": "body",
"type": "array<string,string>",
"contentType": null,
"fix": null,
"children": [],
"choice": null,
"min": null,
"max": null,
"pattern": null,
"rules": {
"description": "Request data"
},
"message": null, <----------------------
"method": null,
"apiClassInstance": null
}
```
tilo
July 3, 2025, 9:45am
7
The patch worked like a charm. POST /members give http 200. The member record is getting created now.
Saved my day.
Thanks.
1 Like