question

Cristian Bontas avatar image
Cristian Bontas asked

REST api endpoints that return 404

Hello

There is at least one REST API that returns 404 http code when the arguments point to invalid data: MultiplayerServer/UpdateBuildAlias returns the following, when given an invalid build id:

{
    "code": 404,
    "status": "NotFound",
    "error": "MultiplayerServerNotFound",
    "errorCode": 1385,
    "errorMessage": "MultiplayerServerNotFound - DeploymentNotFound - The deployment with titleId XXX and deploymentId YYY was not found."
}

(I've removed the ID's)

I've got this by using Postman, and here we get to the point of the bug report.

The C# SDK handles the 404 response particularly, see line 79 in https://github.com/PlayFab/CSharpSDK/blob/master/PlayFabSDK/source/PlayFabHttp/PlayFabSysHttp.cs

if (string.IsNullOrEmpty(httpResponseString) || httpResponse.StatusCode == System.Net.HttpStatusCode.NotFound)                {                    error.HttpCode = (int)httpResponse.StatusCode;                    error.HttpStatus = httpResponse.StatusCode.ToString();                    return error;                }

This means that if the API itself returns a 404 it is handled exactly the same as calling an invalid url and the http server returning a 404, and all the error information returned by the API is lost. As a user of the SDK it is not even possible to know which of the two situations happened.

I suggest changing the API to respond with 400. Once because this is what the docs say it should return, and second because 404 has a big chance of causing confusion anyway and possibly need special handling in user code too.

Regards

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

Yes, I can reproduce this issue, I will report this to related teams, thanks for your feedback:)

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

franklinchen avatar image franklinchen commented ·

The fix has been deployed to the latest C# SDK.

1 Like 1 ·
Cristian Bontas avatar image Cristian Bontas franklinchen commented ·

Great, thanks!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.