Unable to set billing period on line items via the API

SOLVE
IWebster
Participant

Hi,

 

I'm submitting a post request to the v3/objects/line_items end point with the following JSON;

{
    "properties": {
        "name": "bought Plastic - Ergonomic Wooden Towels",
        "price": 102.57,
        "hs_product_id": "1091223719",
        "quantity": "1",
        "hs_recurring_billing_period": "24",
        "recurringbillingfrequency": "monthly"
    }
}

which matches the example in the API documentation for line items, however I get the following error back from the API when submitting the request;

{
    "status": "error",
    "message": "Property values were not valid: [{\"isValid\":false,\"message\":\"The recurring billing duration '24' is not a valid billing duration\",\"error\":\"INVALID_RECURRING_BILLING_DURATION\",\"name\":\"hs_recurring_billing_period\"}]",
    "correlationId": "5812b210-c246-435f-a17a-d7c9abf0ed28",
    "category": "VALIDATION_ERROR"
}

I've tried variations for the billing period field including setting different numbers (e.g. 2, 12, etc) and also setting it as a number rather than a string but get the same result regardless.

 

What am I doing wrong here?

 

Thanks.

0 Upvotes
1 Accepted solution

Accepted Solutions
JBeatty
Solution
Top Contributor | Platinum Partner

Hi @IWebster,

 

I know it's not well documented, and the Line Items API should actually be fixed for this, but the error you are receiving is correct. "24" is actually not a valid recurring billing duration value. If you go and perform a request at the GET/crm/v3/objects/line_items endpoint you will see that recurring billing duration is actually supposed to be of the format "P24M". So it should be a string "P(Insert an integer here)M" and that is the proper value for that field. 

✔️ Was I able to help answer your question? Help the community by marking it as a solution.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk

View solution in original post

3 Replies 3
JBeatty
Solution
Top Contributor | Platinum Partner

Hi @IWebster,

 

I know it's not well documented, and the Line Items API should actually be fixed for this, but the error you are receiving is correct. "24" is actually not a valid recurring billing duration value. If you go and perform a request at the GET/crm/v3/objects/line_items endpoint you will see that recurring billing duration is actually supposed to be of the format "P24M". So it should be a string "P(Insert an integer here)M" and that is the proper value for that field. 

✔️ Was I able to help answer your question? Help the community by marking it as a solution.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk

View solution in original post

IWebster
Participant

Thanks @JBeatty, that has resolved the issue.

 

You are correct - the documentation is quite poor there, it actually gives pretty much my exact JSON as an example for the create line item end point.

 

I assume the "M" in your example is the duration units (M = months)?
0 Upvotes
JBeatty
Top Contributor | Platinum Partner

I believe so @IWebster, though I am unsure if any other units are supported, though it wouldn't be hard to test. In my quick looking around all of my line items are off the form "P#M" no other letters that I can see, though it wouldn't hurt to do a quick test.

✔️ Was I able to help answer your question? Help the community by marking it as a solution.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk