Could you please let me know if there is any part of the code that is wrong?
Page 1 / 1
Hi, welcome to the forum.
Just by looking at the code snipet I don’t see anything wrong, but I also cant tell what error it is.
Do you have any extra information, such as did you get back an HTTP error code from the API.
My suggestions is to try that same PUT via Postman just to try to surface the issue.
In the mean time, it does seem you’re trying to use the API directly via PowerShell, and I’m wondering if you considered using the Box CLI with PowerShell.
Let us know.
Cheers
Hi there.
Thank you for your reply.
The HTTP error code returned by the API is as follows
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
However, the command to change the user name using the same PUT succeeded.
Also, the command to change the user name was successful, and the command execution using Postman was successful.
The Body portion of the successful command is attached to the email.
I considered using the Box CLI with PowerShell, but gave up because I did not know how to change the TrackingCode.
If you could please tell me the command script to run with Box CLI, or the attribute key to include in the CSV file.
Looking closer to the example there seem to be some issues with the strings and possible a JSON formatting, however I believe it would cause another error type on the command, where the JSON formatting would explain the 400 bad request.
I think it still needs for the entire string to be enclosed in “”, there seems to be a missing " on the values, and I think it needs the { and the } in the start and the end.
Could you try using:
$body = oSystem.Text.Encoding]::UTF8.GetBytes(
"{
"tracking_codes": d
{
"type": "tracking_code",
"name":"<tracking code name>",
"value":"<tracking code value> "
}
]
}"
)
Also I’m not sure how powershell handles quotes inside quotes, so you may need to do something else.
In macOS/Linux we need to escape (")
Let us know if this worked.
Best regards
Hi,
I have succeeded by modifying the command as follows.
Also, it would be useful if we could change it all at once in a csv file, so could you please give us a sample code to run in BoxCLI and the attribute key information in the csv file?