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 /
  • API and SDK Questions /
avatar image
Question by matt-3 · Aug 15, 2017 at 08:02 AM · In-Game Economy

Grant Item in Unity

I am trying to grant an item to a user (non- purchase) in a Unity3D game. I see the GrantItemsToUsers in the docs but I dont see it in the API.

Is this possible? If not, what is the best way to give a user an inventory item?

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 15, 2017 at 08:03 AM

There are two possible API calls you may be looking for:

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

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

Can you check to make sure you've enabled the Server API in your project?

Comment

People who like this

0 Show 3 · 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 matt-3 · Aug 16, 2017 at 02:18 AM 0
Share

@Brendan Thanks, I added the Server API and now can see the Grant item code. However, I am getting an invalid parameter when using this Unity code:

publicvoidGrantItem(string itemType)
{
varrequest=newGrantItemsToUsersRequest();
request.ItemGrants=newList<ItemGrant>();
request.ItemGrants.Add(newItemGrant{PlayFabId = UserInfo.PlayerData.id});
request.ItemGrants.Add(newItemGrant{ItemId =itemType});

PlayFabServerAPI.GrantItemsToUsers(request,LogSuccess,LogFailure);
}

Am I not building the list correct?

avatar image Brendan ♦♦ matt-3 · Aug 16, 2017 at 02:21 AM 0
Share

In that code, it looks like you're adding an ItemGrant with the PlayFab ID, and separately adding another with the Item ID set. Each ItemGrant needs to have both set - can you give that a try?

avatar image matt-3 · Aug 17, 2017 at 02:29 AM 0
Share

I see. I got it all working now. Thanks!

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

    How to add PayPal to a game 1 Answer

    Non-receipt payment flow causes most browsers to eat the Facebook Payments pop-up 1 Answer

    Is subscription IAP available for indie tier yet? 2 Answers

    How can I get the custom data from my shop items? 1 Answer

    Is it necessary that the price in RM matches the price in USD in the app store? 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