question

Mubarak Almehairbi avatar image
Mubarak Almehairbi asked

"object" type as query parameter in REST API

Hi,

I am trying to call a function in the Server API using an HTTP request: https://learn.microsoft.com/en-us/rest/api/playfab/server/player-data-management/update-user-read-only-data?view=playfab-rest

However, one of the parameters "Data" is an object. How do I pass an object as a query parameter in the url? I tried several methods but I always get:

{'code': 400, 'status': 'BadRequest', 'error': 'InvalidParams', 'errorCode': 1000, 'errorMessage': 'Invalid input parameters', 'errorDetails': {'Data': ['', 'Must specify at least one of either Data or KeysToRemove.']}}

The URL that I pass looks something like this:

https://{titleid}.playfabapi.com/Server/UpdateUserReadOnlyData?PlayFabId={playfabId}&Data={'{key}': '{value}'}
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.

1 Answer

·
Neils Shi avatar image
Neils Shi answered

As wcf - How to pass object to RESTful Service with GET request? - Stack Overflow mentions that “If you make your service RESTful you will most probably use HTTP PUT for Add method and HTTP POST for Update method. It is absolutely ok to pass object to these methods because object will be part of HTTP request's body, not part of URI”. Since you want to use API UpdateUserReadOnlyData to update user read only data (which should use HTTP POST), you may pass the “Data” parameter in the body of a post request instead of passing it into the URL. In addition, we recommend that you may also use our SDK directly, please refer to Azure PlayFab SDKs - PlayFab | Microsoft Learn for more information.

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.