Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hello,
I wanted to update the "name" field in a document using a curl command.
I used the 2 following command:
- curl --user API_KEY_SECRET: -H 'Content-Type: application/json' -X PUT URL -d '{"login": "sa55", "name": "camille"}'
- curl --user API_KEY_SECRET: -H 'Content-Type: application/json' -X PUT URL/sa55/ -d '{"name": "camille"}'
the first displays no error but does not update the document and the second displays this error
{"errorType": "com.dataiku.common.server. DKUControllerBase$MalformedRequestException", "message": "User login does not match requested URL", "detailedMessage": "User login does not match requested URL", "detailedMessageHTML": "\u003cspan\u003e\u003cspan class\u003d\"err-msg\"\u003eUser login does not match requested URL\u003c/span\u003e\u003c/span\u003e", "stackTrace":[]}.
knowing that the GET command works fine.
here's the schematic of my json file.
[
{
"login": "sa55",
"name": "sara"
},
{
"login": "sa56",
"name": "Sophie"
}
]
hope you can help me
HELLO,
finally I used this query which can have the results of a GET command and modify a specific field via a curl PUT request:
curl -X GET '<GET_URL>' | sed 's/<old_value>/<NEW_VALUE>/g' | curl -X PUT -H "Content-Type: application/json" -d @- '<PUT_URL>'
In this example, I used the curl command to send a curl GET request to the URL <GET_URL>, then the sed command to replace the specified value <old_value> with the new value <NEW_VALUE>.
Thank you.
Welcome to the dataiku community. We are so glad to have you here.
In reading your post I have a few thoughts
Hope that one of these might be of a little help to you.
Hello,
thank you for your reply.
yes I have already used this plugin and it works well with the GET and it displayed the same errors in the case of PUT
Finally in rereading your post. You note that the GET command works but the PUT command does not work. That makes me wonder if your API key has write access in the destination database. I check with the API provider to make sure that my API key has the ability to do a PUT. These kind of things I tend to do from Postman. Because most folks who work with API know the tool and itโs error messages are fairly good.
Again I hope that some of these ideas might be useful.
Hello,
I just found the problem, you have to write all the fields + the field to update in the request ( -d '{"key1": "value1", "key2": "value2", ....}' ) but it's not very useful because I have a lot of field. I want a query where I can modify the specific field without writing all the other fields.
Check with your api provider. It is typical in my experience that one does not need to include all values, but often need to include more values than you might want.
you can often do a get, put, get sequence.
get all of the values from the api
put all the values back with the changes you need to make
get all the values to confirm that your changes have been made
good luck.
thank you!!
HELLO,
finally I used this query which can have the results of a GET command and modify a specific field via a curl PUT request:
curl -X GET '<GET_URL>' | sed 's/<old_value>/<NEW_VALUE>/g' | curl -X PUT -H "Content-Type: application/json" -d @- '<PUT_URL>'
In this example, I used the curl command to send a curl GET request to the URL <GET_URL>, then the sed command to replace the specified value <old_value> with the new value <NEW_VALUE>.
Thank you.