4 Replies Latest reply on Jul 11, 2019 10:01 AM by XMaskuli

    Posting places avatar using REST API


      my first post and sorry to bring up an old question but I am really struggling with this one. I am trying to post an image as the avatar to a newly created space. I have been referencing this and this previous discussions.


      I believe I have to first upload the image to the server. OK no problem:


      $ curl --user "${UserName}:${PassWord}" --request POST --form "file1=@${AvatarFile};type=image/png" "https://foo.bar.com/api/core/v3/images"



        "id" : "25942",

        "contentType" : "image/png",

        "name" : "random.png",

        "ref" : "https://foo.bar.com/api/core/v3/images/25942",

        "size" : 236820,

        "type" : "image"



      Then reference this image when setting the avatar. And here's the problem:


      $ curl --user "${UserName}:${PassWord}" --request POST https://foo.bar.com/api/core/v3/places/${placeid}/avatar?uri=https://foo.bar.com/api/core/v3/images/25942


      But in response, I get:

      {"error":{"message":"There was an error fetching file https://foo.bar.com/api/core/v3/images/25942. HTTP error code: 401","status":400}}


      I have tried urlencoding and that makes no difference. If I pull an image from a public web server then it works fine but I really do not want to have to post these images up publicly simply because of the hassle of setting up something to host them on.


      So what am I doing wrong? Thanks in advance.