Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • General Discussion /
avatar image
Question by games · Aug 23, 2018 at 04:03 AM · CloudScript

CloudScript fails when accessing URL property in object

I'm trying to use CloudScript to get the URL of my Facebook profile picture so I can set it as my PlayFab Avatar.

/*{ // This is the JSON structure returned by the http request 
    "picture": {
      "data": {
        "height": 50,
        "is_silhouette": false,
        "url": "https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=10155832140626538&height=50&width=50&ext=1537585061&hash=AeRvbpI6EulgctDz",
        "width": 50
      }
    },
    "id": "10155832140626538"
  }*/
  var url = "https://graph.facebook.com/me/?fields=picture&type=square∾cess_token="+authToken;
  var method = "get";
  var contentBody = "";
  var contentType = "application/json";
  var headers = {};
  var responseString = http.request(url,method,contentBody,contentType,headers); 
  
  var payload = JSON.parse(responseString);
  return (((payload || {}).picture || {}).data || {}).url;

I can access the "picture" and "data" property of the JS object, but never the "url". I can even access the "height", "is_silhouette", and "width" properties by replacing "url" with those properties.

But ... when I access the "url" property, the code stops working, throwing

{
    "FunctionResult": null,
    "Logs": null,
    "ExecutionTimeSeconds": 0,
    "MemoryConsumedBytes": 0,
    "APIRequestsIssued": 0,
    "HttpRequestsIssued": 0,
    "Error": {
        "Error": null,
        "Message": "There was a problem running testPic. Check your arguments and try again.",
        "StackTrace": null
    }
} 

Is PlayFab blocking or reserving the "url" keyword? I know it's not a JS thing because JS doesn't behave this way, and the code works fine outside of PlayFab.

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Brendan · Aug 23, 2018 at 06:11 AM

No, we don't block or reserve URL (or url). Can you write your payload to the log, to see what it actually contains?

Comment

People who like this

0 Show 2 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image games · Aug 23, 2018 at 06:45 AM 0
Share
{
    "FunctionResult": null,
    "Logs": [
        {
            "Level": "Debug",
            "Message": "{\"picture\":{\"data\":{\"height\":50,\"is_silhouette\":false,\"url\":\"https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=10155832140626538&height=50&width=50&ext=1537597911&hash=AeSK7VTnDou3sTUJ\",\"width\":50}},\"id\":\"10155832140626538\"}",
            "Data": null
        }
    ],
    "ExecutionTimeSeconds": 0.193594,
    "MemoryConsumedBytes": 32456,
    "APIRequestsIssued": 0,
    "HttpRequestsIssued": 1,
    "Error": null
}

It works fine on a JS editor:

https://www.w3schools.com/code/tryit.asp?filename=FUJMM3FECNEG

avatar image Brendan ♦♦ games · Aug 23, 2018 at 07:21 AM 0
Share

Actually, I'm finding that you get the same result trying to return is_silhouette. The problem is due to the return being unable to handle the value itself. It works for me if you stringify the value you're returning:

var urlString = JSON.stringify(payload.picture.data.url);
return urlString;

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    2 People are following this question.

    avatar image avatar image

    Related Questions

    Time Locked Items 3 Answers

    Cloudscript and receiving a callback from Mopub's Rewarded Video Ads 1 Answer

    Is there any way to Create a character with data on it, similar to the grant items to users api call? 1 Answer

    CloudScript execution time includes server warmup 1 Answer

    Using single variable increment for every user. unity3d 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges