APIs & Integrations

IWebster
参加者

Unable to set billing period on line items via the API

解決

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 いいね!
1件の承認済みベストアンサー
JBeatty
解決策
ガイド役 | Diamond Partner
ガイド役 | Diamond Partner

Unable to set billing period on line items via the API

解決

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

元の投稿で解決策を見る

4件の返信
JBeatty
解決策
ガイド役 | Diamond Partner
ガイド役 | Diamond Partner

Unable to set billing period on line items via the API

解決

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

BenGale
投稿者

Unable to set billing period on line items via the API

解決

Is there a way to escalate this to someone to update the documentation? This was pointed out almost a year ago now and it's just tripped me over because the documentation is still wrong.

0 いいね!
IWebster
参加者

Unable to set billing period on line items via the API

解決

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 いいね!
JBeatty
ガイド役 | Diamond Partner
ガイド役 | Diamond Partner

Unable to set billing period on line items via the API

解決

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