REST api add JSON parameter to host

Hello,

I try to add a host parameter with the api, but the value is always empty.

The curl command is:
curl -X POST -H “Content-Type: application/json” -u api_user:password -d ‘{“parameter”:{“parameter_type”:“json”,“name”: “Foobar”, “value”:{“test”:{“foo”:“bar”,“id”:12345}}}}’ https:///api/hosts/797/parameters

The result is:
{“priority”:70,“created_at”:“2019-09-17 09:42:44 UTC”,“updated_at”:“2019-09-17 09:42:44 UTC”,“id”:260,“name”:“Foobar”,“parameter_type”:“json”,“value”:null}

The host parameter is created successful, but the value is empty.

If I add the JSON string ({“test”:{“foo”:“bar”,“id”:12345}}) via the WebUI with type ‘json’, the value is filled correct and I can access the values with puppet.

Can somebody help me or give me a hint?

We use Foreman 1.22 with Katello 3.12 on CentOS 7.

Many thanks, Stefan.

I have found the solution.
The inner JSON part have to be a string:
{“parameter_type”:“json”,“name”: “Foobar”, “value”:"{“test”:{“foo”:“bar”,“id”:12345}}"}}

I have found the solution.
The inner JSON part have to be a string:

{“parameter_type”:“json”,“name”: “Foobar”, “value”:"{“test”:{“foo”:“bar”,“id”:12345}}"}}

Sorry for the posts. The forum removes the backslashes ahead the dopple quotes.
So type a backslash ahead the doppel quotes in the inner JSON part:
“{“test”:{“foo”:“bar”,“id”:12345}}”