Hello I've read the docs and wiki about the API but I can't manage to post an image through the API (so with a script). I managed to upload a file with this command :
curl -s -u "$USERNAME:$API_KEY" \
-F "upload[files][0]=@my_image.jpg" \
"https://danbooru.donmai.us/uploads.json"which gives lots of IDs and upload IDs like this :
{
"id": 57718425,
"status": "completed",
"upload_media_assets": [
{
"id": 83287945,
"upload_id": 57718425,
"media_asset_id": 48678642,
"status": "active",
"source_url": "file://my_image.jpg",
"media_asset": {
"id": 48678642,
}
]
}The docs (api:posts) then says to post an image you need to do this :
curl -s -u "$USERNAME:$API_KEY" -X POST "https://danbooru.donmai.us/posts.json" -d "post[upload_media_asset_id]=83287945" -d "post[tag_string]=tagme 1girl standing" -d "post[rating]=g"
But this gives me :
{
"success": false,
"error": "ActiveRecord::RecordNotFound",
"message": "That record was not found.",
"backtrace": [
"app/controllers/posts_controller.rb:62:in 'PostsController#create'",
"app/logical/rack_server_timing.rb:19:in 'RackServerTiming#call'"
]
}So I guess my ID is wrong. I've then also tried :
curl -s -u "$USERNAME:$API_KEY" -X POST "https://danbooru.donmai.us/posts.json" -d "post[upload_media_asset_id]=57706306" -d "post[rating]=g" curl -s -u "$USERNAME:$API_KEY" -X POST "https://danbooru.donmai.us/posts.json" -d "post[upload_media_asset_id]=48678642" -d "post[rating]=g" curl -s -u "$USERNAME:$API_KEY" -X POST "https://danbooru.donmai.us/posts.json" -d "post[upload_id]=57718425" -d "post[rating]=g" curl -s -u "$USERNAME:$API_KEY" -X POST "https://danbooru.donmai.us/posts.json" -d "post[media_asset_id]=48678642" -d "post[rating]=g"
But I keep receiving the same error "That record was not found.".
Does anybody know how to post correctly ? What ID should I use ?
Thank you.
Updated by MrShiruba
