question

bjornritzl avatar image
bjornritzl asked

Issue with URL creation in the LuaSDK

I noticed a post on the Defold forum mentioning issues when making PlayFab API requests in Defold on desktop (HTML5 builds are fine) (Defold forum post). The conclusion from @Brendan was that "For this issue, I’d say the problem is the extra “/” in the URL (making the URL invalid). So the call isn’t actually getting out to us at all"

Now, I took a look at the LuaSDK code and came to this conclusion:

If we look at the PlayFabHttps_LuaSec.lua file (https://github.com/PlayFab/LuaSdk/blob/master/PlayFabClientSDK/PlayFab/PlayFabHttps_LuaSec.lua#L18-L31) we see that the fullUrl is constructed like this:

local fullUrl ="https://".. PlayFabSettings.settings.titleId..".playfabapi.com/".. urlPath

The same goes for PlayFabHttps_Defold.lua that is in PlayFabClientSdk.zip (btw where is the source to PlayFabHttps_Defold.lua in the repo?).

Now, if we look at the code that is calling MakePlayFabApiCall we see this:

IPlayFabHttps.MakePlayFabApiCall("/Client/AddFriend", request, "X-Authorization", PlayFabSettings._internalSettings.sessionTicket, onSuccess, onError)

The urlPath that is passed as first argument to PlayFabHttps_LuaSec.MakePlayFabApiCall (and the equivalent for Defold) starts with a '/' which will make the fullUrl have two '/' in a row. This will cause problems on some platforms as was observed in the original post on the Defold forum.

I'm willing to submit a PR but I as I wrote above I can't seem to find the code for PlayFabHttps_Defold.lua.

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

·
1807605288 avatar image
1807605288 answered

You are correct!

Thanks for reporting this error, I'll fix it immediately.

The code you're looking for would be in the SdkGenerator. That is a program that builds all of our SDKs, including some files that are used to make builds, but not actually published, such as this case.

In this case, I'll just make the fix immediately, but feel free to take a look at the repo for future use.

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

bjornritzl avatar image bjornritzl commented ·

Ah, there its is! Brilliant! Thanks.

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ commented ·
0 Likes 0 ·
Danny avatar image Danny commented ·

@Paul Gilmore

I'm still facing the same problem here: https://github.com/PlayFab/LuaSdk/tree/master/Defold

I think the PlayFabClientSdk.zip hasn't been updated yet

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ commented ·

You're correct, it has not.

Apologies, I released a hotfix for Unity issues, but I forgot about the Lua issue.

I'll release it today.

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ commented ·

Done! You should be good to go.

0 Likes 0 ·
Danny avatar image Danny 1807605288 ♦ commented ·

Thank you!

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.