简体   繁体   中英

Artifactory REST API rejects valid JSON

I am passing the following call to the Artifactory REST API which is resulting in "Unexpected character ('e' (code 101)): expected a valid value

However, this JSON is dead simple and valid:

{
    "exportPath": "Invalid"
}

The curl looks like this:

curl -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d export-settings.json -X POST https://artifactory.i.build.mgp.ninja/artifactory/api/export/system

I also tried using application/vnd.org.jfrog.artifactory.system.ExportSettings+json as the Content-Type header which gave me a 400 (I saw this pattern in other places, though it is foreign to me).

What could be causing this? The docs don't go into much depth.

Note: I first hit errors writing a Golang wrapper for this API, where I got 415's.

I think the way th curl is being sent is incorrect, when using -d option and passing the JSON file, '@' should be used. So the below curl command should be helpful,

curl -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d @export-settings.json -X POST https://artifactory.i.build.mgp.ninja/artifactory/api/export/system

Or use the below curl command to test if the JSON is being taken as a valid or not,

curl -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"exportPath":"Invalid"}' -X POST https://artifactory.i.build.mgp.ninja/artifactory/api/export/system

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM