I am trying to format a REST API call, but the docs of the API provider are not very clear.
This what I get from the API provider.
# checkout a new subscription with addons.
curl https://{site}.chargebee.com/api/v2/hosted_pages/checkout_new \
-u {site_api_key}:\
-d customer[email]="john@user.com" \
-d customer[first_name]="John" \
-d customer[last_name]="Doe" \
-d customer[locale]="fr-CA" \
-d customer[phone]="+1-949-999-9999" \
-d subscription[plan_id]="no_trial" \
-d addons[id][0]="sub_monitor" \
-d addons[unit_price][0]=100 \
-d addons[quantity][0]=2
I have tried this
and this.
But I always get this error.
{
"code": 0,
"message": "subscription[plan_id] : cannot be blank"
}
Any ideas?
Hello @Andreas_Marinopoulos
I assume you need to use a Create Request Form
instead of a Create Object
block
Still does not work, do you see anything wrong?
I am getting
{
"code": 0,
"message": "{\"errors\":[{\"message\":\"There were errors while submitting\"},{\"param\":\"subscription[plan_id]\",\"message\":\"cannot be blank\"}]}"
}
try to use only one Form (the first one) and then connect Create Object
Or, maybe you should specify properties for the form as:
subscription[plan_id]
(without nested blocks)
Still getting the same error both with the form without nested blocks as well as the form + object. Any other ideas?
1 Like
I was told
- inputs (plan id) is passed outside of the scope of the place where the API call is initiated.
but I have no idea what that means
although I wouldn't be able to specifically point out which part of the code is causing the error, I can surely see that the above code is not able to identify the inputs passed to it, which is why you are seeing the error.
Could you please check this with your developers. They should be the right person to assist you on this.```
I recommend moving the logic to a UI builder page (temporarily) so you can see in the Network tab of the browser devtools what the request looks like. Please do that and share with us a screenshot of the codeless logic and the payload generated by the request.
Here s the codeless logic
When I try from the UI builder page, I get this error:
And the network tab looks like this
1 Like
Looks like their server is not handling cors requests properly. That’s unfortunate.
What does their server respond with when you make that request from an API service?
@mark-piller It responds one of the following, depending on how I set it up.
{
"code": 0,
"message": "subscription[plan_id] : cannot be blank"
}
{
"code": 0,
"message": "source.on is not a function"
}
{
"code": 0,
"message": "{\"errors\":[{\"message\":\"There were errors while submitting\"},{\"param\":\"subscription[plan_id]\",\"message\":\"cannot be blank\"}]}"
}
{
"code": 0,
"message": "subscription[plan_id] : The \"4wk-main-plan\"*subscription[plan_unit_price]=3500 referenced in parameter subscription[plan_id] is not present "
}
The 4th error which is the closest to it working was when I put the parameters in the url like thisNot sure if this helps, but this Zapier setup works perfectly:
image10081190×246 34.1 1712 225 KB
The 4th error which is the closest to it working was when I put the parameters in the url like this:
What is the reason you put 4wk-main-plan
into single quotes?
Have you tried making a request without them?
1 Like
It worked! Thanks
Specifically this is what worked: