question

Carlos avatar image
Carlos asked

Catalog/Search item returns Invalid Request error when using the "Search" parameter from web

This endpoint "playfabapi.com/Catalog/SearchItems" will not work from browsers when using the "Search" parameter. It returns this error:

{ "code": 400, "status": "BadRequest", "error": "InvalidRequest", "errorCode": 1071, "errorMessage": "Invalid request Correlation Id: WHi73GdpWE6XTgaw6xsW3g.0", "errorDetails": { "MS-CV": [ "WHi73GdpWE6XTgaw6xsW3g.0" ] } }

The same request with the same body and the same authentication header will work correctly from something other than a browser (like postman or a node server).

After many hours of investigation, we noticed that the browser automatically adds this header to the POST request: "Accept-Language: en-US,en;q=0.5".

Only the Search parameter trips the error, so this will work: { "Store": { "AlternateId": { "Type": "FriendlyId", "Value": "someStore" } }, "OrderBy": "Title/NEUTRAL desc" }

But this won't: { "Search": "green", "Store": { "AlternateId": { "Type": "FriendlyId", "Value": "someStore" } }, "OrderBy": "Title/NEUTRAL desc" }

If I override it to "Accept-Language: en-US", it'll go through without errors.

apis
10 |1200

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

kylemc@microsoft.com avatar image
kylemc@microsoft.com answered

Long story, but I'll try not to bore you. The original design used the Accept-Language header for localization, but we discovered after we shipped that it wouldn't work in a few of the SDKs. We've since added the Language field to the request to make the feature work everywhere. The header support still exists, but I'm wondering now if we should just deprecate it to avoid this bug. It also sounds like we should update our documentation. Thanks for bringing the issue up.

https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/catalog/search#localization https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/catalog/localization

10 |1200

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

Xiao Zha avatar image
Xiao Zha answered

Thanks for pointing this out. If you want to test PlayFab APIs, we’d recommend using Postman as per Quickstart PlayFab REST API collection for Postman - PlayFab | Microsoft Learn.

10 |1200

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

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.