Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question CCD Client API receiving 301 Moved Permanently

Discussion in 'Unity Cloud Content Delivery' started by MaxDeBy, Jun 26, 2023.

  1. MaxDeBy

    MaxDeBy

    Joined:
    Dec 4, 2016
    Posts:
    5
    I'm trying to implement the CCD Client API, as we've decided not to use Addressables due to how our content is managed.

    But I'm encountering an odd behavior and I cannot figure out where I'm wrong.

    In particular, I am trying to call this endpoint here:
    https://<PROJECTID>.client-api.unity3dusercontent.com/client_api/v1/environments/<ENVIRONMENTID>/buckets/<BUCKETID>/release_by_badge/latest/

    When using this endpoint in Postman it works just fine. However when using it in Unity, or rather .NET directly via the HttpClient, I receive a 401 Unauthorized response. After some sniffing is done, it turns out that my request is redirected due to a 301 Moved Permanently response. The redirected request doesn't attach the Authorization header, however. That by itself can be managed but I don't get why I'm redirected in the first place.

    What's even more confusing is, that the route I'm being redirected to is "/client_api/v1/environments/<ENVIRONMENTID>/buckets/<BUCKETID>/release_by_badge/latest/", aka...the exact same path that I've requested in the first place. According to the HttpClient, the final request, that receives the 401 response is at "https://<PROJECTID>.client-api.unity3dusercontent.com/client_api/v1/environments/<ENVIRONMENTID>/buckets/<BUCKETID>/release_by_badge/latest/?Location=%2Fclient_api%2Fv1%2Fenvironments%2F<ENVIRONMENTID>%2Fbuckets%2F<BUCKETID>%2Frelease_by_badge%2Flatest"

    If anyone could point out to me what I might be doing wrong, that'd be greatly appreciated. Gotta be some logic error in my thinking or perhaps an absolute minimal typo? I can't figure it out at all, however.
     
  2. timtunity3d

    timtunity3d

    Unity Technologies

    Joined:
    Oct 1, 2015
    Posts:
    131
  3. MaxDeBy

    MaxDeBy

    Joined:
    Dec 4, 2016
    Posts:
    5
    That's not the issue. The permissions were already set. As mentioned in my post, if I'm using Postman with the same value for the Authorization header, it works just fine. Just with the C# HttpClient I get redirected to the same link. So I was wondering whether that's intentional.
     
  4. timtunity3d

    timtunity3d

    Unity Technologies

    Joined:
    Oct 1, 2015
    Posts:
    131
    Ah sorry, I missed that bit. And your original URL definitely has a trailing slash?
     
  5. MaxDeBy

    MaxDeBy

    Joined:
    Dec 4, 2016
    Posts:
    5
    Oof...I didn't even consider that. Yeah that fixed it. I had to put one on the other endpoints as well. But between the route and the start of the query parameter in case of the "diff" endpoints. A bit of an unusual choice that it depends on a slash being there.

    Thanks for the tip, that solved the issue.