question

Jonathan Crowe avatar image
Jonathan Crowe asked

Powershell Api UpdateBuildAlias BuildSelectionCriteria

Hey folks, I'm struggling to update a build alias via the API using powershell. I can't seem to find the correct body syntax to update the BuildWeightDistribution. I've tried both curl and HTTPie.

 https POST https://myid.playfabapi.com/MultiplayerServer/UpdateBuildAlias X-EntityToken:"mytolken" Content-Type:application/json AliasID=eac3d4fd-fae1-4e68-8b82-f8d01c133a66 AliasName=Development BuildSelectionCriteria:="[{"BuildWeightDistribution":{"5584dfb4-4e5d-47bc-9f4c-42b503bb4ce2":"1"}}]"
    
 Result: 
 'BuildSelectionCriteria:=[{BuildWeightDistribution:{5584dfb4-4e5d-47bc-9f4c-42b503bb4ce2:1}}]': Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

 Invoke-WebRequest "https://myid.playfabapi.com/MultiplayerServer/UpdateBuildAlias" -Method POST -Headers @{"Content-Type" = "application/json"; "X-EntityToken" = "mytolken";} -body @{"AliasId" = "eac3d4fd-fae1-4e68-8b82-f8d01c133a66"}
    
 Result 
 Invoke-WebRequest : {"code":400,"status":"BadRequest","retryAfterSeconds":null,"error":"InvalidRequest","errorCode":1071,"errorMessage":"Invalid JSON in
 request","errorHash":"2f36f079c8f0511f52a0125f636ca730","errorDetails":{"ValidationError":["Unexpected character encountered while parsing value: A. Path '', line 0, position 0."]}}

Could i have a sample of the syntax to use to access the BuildWeightDistribution please.

Many thanks.

apis
2 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.

Jonathan Crowe avatar image Jonathan Crowe commented ·

Adding the following to a file

 [{
     "BuildWeightDistribution":{"mybuildis":"1"}
 }]

Then loading it via the httpie command

https POST https://F32BC.playfabapi.com/MultiplayerServer/UpdateBuildAlias X-EntityToken:"mytooklen" Content-Type:application/json AliasID=myID AliasName=Development BuildSelectionCriteria:=@jsonsample.json

Works. So what is the syntax for the commandline?

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha Jonathan Crowe commented ·

I will do some research.

1 Like 1 ·

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

You can try this command: https POST https://myid.playfabapi.com/MultiplayerServer/UpdateBuildAlias X-EntityToken:"mytoken" Content-Type:application/json AliasID=myid AliasName=Test BuildSelectionCriteria: "[{"BuildWeightDistribution":{"mybuildId":"1"}}]". And you can also try another command: echo ‘your request body’ | https POST https://myid.playfabapi.com/MultiplayerServer/UpdateBuildAlias X-EntityToken:"mytoken" Content-Type:application/json. The two commands work fine in my powershell test. For more information, you can refer to Raw request body - HTTPie 3.2.1 (latest) docs.

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.