question

max avatar image
max asked

AddFriend on the Server has no return value, but it has on the Client

Sorry if this is a known issue. We found out today that AddFriend on the Server API is only returning EmptyResult, while calling from the Client API returns whether the friend was created or not.

https://api.playfab.com/documentation/client/method/AddFriend

https://api.playfab.com/documentation/server/method/AddFriend

apisFriends
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

·
brendan avatar image
brendan answered

Yes, that's due to an inconsistency in the implementation between the two calls from back when they were created. We periodically update with new calls, deprecating old ones, in order to get this sort of thing cleaned up, but there are two things to be aware of:

1. We're committed to having no breaking changes. While adding a return value seems like it wouldn't impact any existing titles, we can't actually guarantee that, so when we do get to updating this one, we'll likely deprecate the existing call and replace it.

2. If there are no errors returned on the Server API call, it was successful. The Created = true response from the Client API call is actually redundant (and so, that may actually be the call we deprecate and replace). The 200 response is already saying the call was processed successfully.

4 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.

max avatar image max commented ·

About 2) Okay, but how do we check for the actual response / response codes when doing these calls in Cloud Script? Let's say we call AddFriend. According to the docs here (https://api.playfab.com/documentation/server/method/AddFriend) it has a few possible error codes. How do we get these if there is no return value?

Do we have to handle this somehow via try & catch / what's the designated way to do that?

0 Likes 0 ·
brendan avatar image brendan max commented ·

There's always a return value. Even in the case where you have no internet connection, you should get an error response back from your library code indicating this. The normal method we recommend is to use lambda-style handling of the success/failure conditions, as shown in our samples. For example, have a look at the OnLoginSuccess and OnLoginError handling in the LoginWithCustomID call in our Getting Started sample: https://github.com/PlayFab/PlayFab-Samples/tree/912e97f19866dd6ef539f5d9853195aad16c6d3c/VideoTutorialSamples/GettingStarted.

0 Likes 0 ·
max avatar image max brendan commented ·

I think you are talking about code on the client right? There it is indeed easy to get the error response back. I was wondering how to get it in CloudScript (JavaScript / TypeScript) when using the Server-API.

0 Likes 0 ·
Show more comments

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.