Hello,
So, I am trying to create a pack to connect to the Veeam API.
This particular one is using sessions, so I need to call a POST method to retrieve the token.
The issue is that the builder always states that it is unable to parse the body as a json object and it is sending it as a raw string, which is not something that the API likes.
I've tried modifying the body in a lot of ways but I get the same error no matter what I do.
Did anyone encountered this before? is there a workaround?
I've found this link (vRealize Operations Management Pack Builder - Building your first management pack (veducate.co.uk)) that uses the beta version and actually connects to the Veeam API, but the same settings do not work in my case.
Thank you,
Paul
For anybody that has this issue. I managed to make it work by changing the content-type.
Although the Veeam documentation asks for the content type to be set as application/x-www-form-urlencoded, just set is as application/json
The body needs to be a valid JSON.
This will work.
Thank you,
Paul
Hi @Paul87,
We've not had any issues reported around sending a JSON body in a POST request with MP Builder.
A few questions to help troubleshoot:
1. What version of MP Builder are you using? What version of the Veeam API?
2. Have you set the "Content-Type" query parameter for your POST request?
3. I can't speak to the correctness of that 3rd-party blog. It looks like the body they're using (starting with "grant_type=") is not JSON. You can use various free tools for validating JSON.
The Veeam API documentation may provide an example body that you can reference.
Please feel free to post screenshots here (be careful not to expose any sensitive information), or you can email us at mp-builder-dev@vmware.com. We'd also be happy to jump on a call to help.
Best regards,
Mark
Hello @marbogast ,
Thank you for your reply.
The MP builder is at the latest version. 1.1.0.
I actually have 3 API versions for Veeam. But this is not an issue with the Veeam API. It is responsive. I've tried this connection from a linux box, from Windows using PowerShell and from Postman. All are successful.
This is the Content-Type:
The 3rd party blog is referenced by VMware documentation - Management Pack Builder - VMware Technology Network VMTN
The builder wants to parse the body as JSON and it fails. It even does so when I enter valid JSON. I tried all possible combinations, but it just send the body as raw string.
This is the API log.
The same call done from Postman has this in the API log:
I do not understand how should I write this bit, in order for the parser to not error out.
Thank you,
Paul
Hello @marbogast ,
I've tried sending you guys an e-mail, but I am not whitelisted. I've tried using two different e-mail addresses.
Thank you,
Paul
For anybody that has this issue. I managed to make it work by changing the content-type.
Although the Veeam documentation asks for the content type to be set as application/x-www-form-urlencoded, just set is as application/json
The body needs to be a valid JSON.
This will work.
Thank you,
Paul
Hi @Paul87,
Glad you were able to find a workaround! Thank you for sharing your solution for others.
Strangely, we were not able to reproduce this issue in our lab. The log about "Could not parse body as a JSON object" is not an error, it's expected behavior for any non-JSON content type (it is misleading; we will look at rewording). And the API's response that grant_type was not specified is also strange - you clearly specified it.
Our best guess is that maybe there was a special character in the password that needed to be url-encoded, thus breaking the entire body of the request.
Regarding the mp-builder-dev@vmware.com address - it appears this email address was made private at some point. My mistake. I have requested it be made public - it may take some time to take effect.
Best regards,
Mark