Version 7 REST Avatar Upload is incorrect

Version 7 REST Avatar Upload is incorrect

  • Excellent to see avatar upload has been included in the version 7 REST API.

    But can someone take a look at the .Net C# Example. It doesn't add any data into the NameValueCollection. As the AvatarData Type is byte[] I assume I add a Base64 string to be posted?

    Thanks

    Fran

  • I've tried using Base64 Encoded string but that doesn't work.

    The HTTP Request looks like

    POST http://.../api.ashx/v2/users/16028/avatar.xml HTTP/1.1

    Rest-User-Token: YnB5aXljMGNjOXdvejNvZDRxZHMxZDphZG1pbg==

    Rest-Method: PUT

    Content-Type: application/x-www-form-urlencoded

    Host: ....

    Content-Length: 20142

    Expect: 100-continue

    UserId=16028&AvatarData=iVBORw0KGgoAAAANSUhEUgAAAFAAAAB ...etc

    The response xml is :

    <?xml version="1.0" encoding="utf-8"?>

    <Response>

      <Info />

      <Warnings />

      <Errors>

        <Message>Parameter is not valid. See Exception Log for details.</Message>

      </Errors>

    </Response>

  • This should help:

    telligent.com/.../20927.aspx

  • Ahh, I'd forgotten that, still having trouble though (and the example is still wrong!)

    The post now looks like:

    POST http://.../api.ashx/v2/users/16031/avatar.xml HTTP/1.1

    Rest-User-Token: YnB5a....pbg==

    Rest-Method: PUT

    Content-Type: multipart/form-data; boundary=0131befff9914a39a2391fb0ac3381c9

    Host: ....

    Content-Length: 14400

    Expect: 100-continue

    --0131befff9914a39a2391fb0ac3381c9

    Content-Disposition: form-data; name="UserId"

    16031

    --0131befff9914a39a2391fb0ac3381c9

    Content-Disposition: form-data; name="AvatarData"; filename="3794-logo.png"

    Content-Type: image/png

    [....data....]

    Without the Put header I get 404, with the Put header I get "Please provide either AvatarUrl or AvatarData"

    Any ideas? I've used this method to successfully upload Media posts and attachments before, so I don't think thats it?

    Thanks,

    Fran

  • There appears to be a bug in the implementation of that REST endpoint where it is not recognizing the uploaded file. I have added a bug for it with a high priority. We should take it for the next hotfix. You can contact our support team for more detailed information referencing bug number 26232.  

  • Thanks Dan, any idea of time scales, we are doing a migration of Jive to Telligent and deadlines are tight.

  • We have already or will soon ship the October hotfix so it won't be included in that. It should be in the November hotfix then which would be released sometime around mid-November.

    There are a couple of workarounds that could be used. One, manually update the user's avatars after they have been imported, which may not be a great idea depending on the community size. Another option if you need the functionality immediately would be to create a custom REST endpoint to do it. Something like this should work: get the uploaded file, add it to the user's file store (PublicApi.UserFiles.Create()), or any other publicly accessible file store for that matter, and then update the user's AvatarUrl to be the url of the one added to the user's file store.

  • Dan,

    Version 6.x of the API allowed me to use the version 5.5 avatar upload api, is this still available in version 7? If not can it be enabled in some way?

    Thanks,

    Fran