APIs & Integrations

telehealth
Participant

Experiencing difficulty retrieving product details through API integration

SOLVE

I am experiencing difficulty generating accurate data through the API integration in Hubspot. I am utilizing PHP with cURL to accomplish this task. Although I am capable of generating all four objects and successfully associating them, when I review my Hubspot application, I am not able to locate any data. For clarity, I have attached a snapshot of the issue. Additionally, I am including a code snippet below to aid in understanding the problem and request your assistance in resolving it.

Following are object JSON structures:

$contact = array(
            'inputs' => array(
                array(
                    'properties' => array(
                        'company' => '',
                        'email' => $email,
                        'firstname' => $firstname,
                        'lastname' => $lastname,
                        'phone' => $mobilephone,
                        'website' => '',
                    ),
                ),
            ),
        );

$product = array(
    "inputs" => array(
        array(
            "properties" => array(
                "description" => $name,
                "hs_cost_of_goods_sold" => $price,
                "hs_recurring_billing_period" => $recuring_period,
                "hs_sku" => '',
                "name" => $name,
                "price" => $price,
               
            ),
        ),
    ),
);

$deal = array(
        "input" => array(
            "properties" => array(
                    "amount" => $amount,
                    "closedate" => $order_created,
                    "dealname" => $ordername,
                    "dealstage" => $order->order_status,
                    "hubspot_owner_id" => "",
                    "pipeline" => "default",
            ),
            "associations" => array(
                array(
                    "to" => array(
                        "id" => $contact_id,
                    )
                ),
                array(
                   
                    "type" => array(
                        "associationCategory" => "HUBSPOT_DEFINED",
                        "associationTypeId" => 3
                    )
                )
            ),
        )
    );

    $order_line_item = array(
        "inputs" => array(
            array(
                "properties" => array(
                    "name" => $product_name,
                    "hs_product_id" => $sku,
                    "hs_recurring_billing_period" => "",
                    "recurringbillingfrequency" => "",
                    "quantity" => $num_items,
                    "price" => $price
                ),
                "associations" => array(
                    array(
                        "to" => array(
                            "id" => $deal_id,
                        )
                    ),
                    array(
                       
                        "type" => array(
                            "associationCategory" => "HUBSPOT_DEFINED",
                            "associationTypeId" => 20
                        )
                    )
                ),
            )
        )
    );

Following are the API endpoints I am using:

$product = 'https://api.hubapi.com/crm/v3/objects/products/batch/create';
$deal = 'https://api.hubapi.com/crm/v3/objects/deal';
$line_item = 'https://api.hubapi.com/crm/v3/objects/line_items';

Following are the outputs:

 product:
  {
    "status": "COMPLETE",
    "results": [
      {
        "id": "2050443311",
        "properties": {
          "createdate": "2023-05-04T19:27:27.641Z",
          "description": "Teaching the History of Racist Policy and Resistance in Rochester: A Case Study in Antiracist Curriculum, Online Self-Study",
          "hs_cost_of_goods_sold": "0",
          "hs_lastmodifieddate": "2023-05-04T19:27:27.641Z",
          "hs_object_id": "2050443311",
          "name": "Teaching the History of Racist Policy and Resistance in Rochester: A Case Study in Antiracist Curriculum, Online Self-Study",
          "price": "0"
        },
        "createdAt": "2023-05-04T19:27:27.641Z",
        "updatedAt": "2023-05-04T19:27:27.641Z",
        "archived": false
      }
    ],
    "startedAt": "2023-05-04T19:27:27.613Z",
  }
 
Deal:
stdClass Object
(
    [id] => 13235011866
    [properties] => stdClass Object
        (
            [createdate] => 2023-05-04T19:27:29.032Z
            [days_to_close] => 0
            [hs_closed_amount] => 0
            [hs_closed_amount_in_home_currency] => 0
            [hs_createdate] => 2023-05-04T19:27:29.032Z
            [hs_deal_stage_probability_shadow] => 0
            [hs_is_closed_won] => false
            [hs_is_deal_split] => false
            [hs_lastmodifieddate] => 2023-05-04T19:27:29.032Z
            [hs_object_id] => 13235011866
            [hs_projected_amount] => 0
            [hs_projected_amount_in_home_currency] => 0
        )

    [createdAt] => 2023-05-04T19:27:29.032Z
    [updatedAt] => 2023-05-04T19:27:29.032Z
    [archived] =>
)

Line Item:
{
"id": "5461976748",
"properties": {
"amount": "0.000",
"createdate": "2023-05-04T19:27:30.606Z",
"hs_acv": "0.000",
"hs_arr": "0.000",
"hs_lastmodifieddate": "2023-05-04T19:27:30.606Z",
"hs_margin": "0.000",
"hs_margin_acv": "0.000",
"hs_margin_arr": "0.000",
"hs_margin_mrr": "0.000",
"hs_margin_tcv": "0.000",
"hs_mrr": "0.000",
"hs_object_id": "5461976748",
"hs_position_on_quote": "0",
"hs_pre_discount_amount": "0.000",
"hs_recurring_billing_number_of_payments": "1",
"hs_tcv": "0.000",
"hs_total_discount": "0.000"
},
"createdAt": "2023-05-04T19:27:30.606Z",
"updatedAt": "2023-05-04T19:27:30.606Z",
"archived": false
}

Despite my efforts, I am still experiencing difficulties obtaining accurate information through my Hubspot application. I kindly request your assistance in identifying a solution for this issue. If there are any mistakes that I may have made, please advise me on how to address them and improve my approach. Thank you for your professional guidance.

I had tried with Postman also, but got the same response from there as well.

Associations are working proper.
line_null.pngnull.pngpost.png

 

 

0 Upvotes
1 Accepted solution
telehealth
Solution
Participant

Experiencing difficulty retrieving product details through API integration

SOLVE

Hey Jaycee
I have obtained the solution. The problem arose due to improper utilization of the JSON structure for deals and line items, along with an incorrect HubSpot ID.
Thank you.

 

View solution in original post

0 Upvotes
3 Replies 3
Jaycee_Lewis
Community Manager
Community Manager

Experiencing difficulty retrieving product details through API integration

SOLVE

Hi, @telehealth 👋 Thank you very much for posting a detailed question. May I check my understanding with you? 

You can create the records — contact, deal, product, line item, and make the desired associations, but when viewed in app, you cannot find them? Is that correct? Or, in the case of your screenshot, you're seeing something in-app, but not what you expect?

 

If so, and you still need help, I am happy to work through an example using Postman and see if we can get it working there. 

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

telehealth
Solution
Participant

Experiencing difficulty retrieving product details through API integration

SOLVE

Hey Jaycee
I have obtained the solution. The problem arose due to improper utilization of the JSON structure for deals and line items, along with an incorrect HubSpot ID.
Thank you.

 

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Experiencing difficulty retrieving product details through API integration

SOLVE

Hey, @telehealth 👋 I'm glad to hear that you resolved the issue. Thank you very much for taking the time to come back and update the community 🙌 — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes