Solved Update category picture (via image upload) API not working

  • @baris thanks, just tried that and it didn't work. Is there a 3rd step to actually placing the image?

  • NodeBB

    Ahh yes you need to set the backgroundImage property of category:2 to the value of "url": "/assets/uploads/category/category-2.png"

  • @baris Thank-you, found it, it is a PUT on the write API. First go, I got the syntax mostly correct, I got a 200 OK message, but the Response:backgroundImage key was empty.

    I will poke at this more after dinner, but I think we can call this one solved, since it is just a matter of figuring out the right syntax at this point.

  • @baris Using the below site, reminding me of just how powerful Chrome Developers tools are, I was able to Copy As Curl the specific PUT command.

    Curl Convert

    Then using the same command and just changing the CID, I confirmed the same command works for all of them.

    This is what ended up working, it includes all the recorded headers, of which some will be removed as not necessary:

    curl '' \
      -X 'PUT' \
      -H 'Connection: keep-alive' \
      -H 'Accept: */*' \
      -H 'DNT: 1' \
      -H 'x-csrf-token: H5FMJEaY-CthHWM_2Unzf7DtoPeryGq_JejE' \
      -H 'X-Requested-With: XMLHttpRequest' \
      -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36' \
      -H 'Content-Type: application/json; charset=UTF-8' \
      -H 'Origin:' \
      -H 'Referer:' \
      -H 'Accept-Language: en-US,en;q=0.9,zh;q=0.8,zh-CN;q=0.7,zh-TW;q=0.6,ja;q=0.5,ko;q=0.4,th;q=0.3' \
      -H 'Cookie: _csrf=27ygKMdG0c0EyiVsJKAkKpId; express.sid=s%3AdODaXfUpLz7NTFsijWLq0d2rPUhH1Ki4.qkyxWOaxlBy%2BLDRpTYbhWS9QkD9IJE%2FRTN1vIhp7yV4' \
      -H 'sec-gpc: 1' \
      --data '{"backgroundImage":"/assets/uploads/category/category-84.jpg"}' \
      --compressed \

    Then using the cURL convert site, was able to save as javascript and modify to our needs so that we could loop through all categories.


  • Topic has been marked as solved  J jpop71 

Suggested Topics

| |