APIs & Integrations

reprtoir
Member

Manipulating Deals pipelines via API is broken

SOLVE

Hi,

It's been several days I'm trying to create and update deals pipeline via the API. After contacting the support several times, they asked me to post in this forum, so here I am.

Summary: The Deprecated Deals pipelines API works to create a pipeline, but not to update it. The new CRM Pipeline API do not work to create a pipeline, but works to update a pipeline (but after the update, everything return 500 errors). Integrating contacts and companies API in my app was easy, deal pipelines it's just a nightmare because there is so many things broken.

Find below several steps

1 - Create a deal pipeline according to the documentation (https://developers.hubspot.com/docs/methods/pipelines/create_new_pipeline)

<- "POST /crm-pipelines/v1/pipelines/deals HTTP/1.1\r\nAuthorization: Bearer CLfoocr4LBICQQEYrsy-AiCY3ukCKOSQCzIZAP4E6-cKglIuOPwS8awnMzzAOyCKHwYaKjoPAAoCRwAADIADAAgAAAABQhkA_gTr55tGOVFXBz16a4wwsE1OF3Y1M7xa\r\nContent-Type: application/json\r\nConnection: close\r\nHost: api.hubapi.com\r\nContent-Length: 258\r\n\r\n"
<- "{\"pipelineId\":\"api_test_pipeline\",\"label\":\"API test pipeline\",\"displayOrder\":1,\"active\":true,\"stages\":[{\"stageId\":\"example_stage\",\"label\":\"Example stage\",\"displayOrder\":1},{\"stageId\":\"another_example_stage\",\"label\":\"Another example stage\",\"displayOrder\":2}]}"
-> "HTTP/1.1 400 Bad Request\r\n"
-> "Date: Fri, 07 Dec 2018 09:31:49 GMT\r\n"
-> "Content-Type: application/json;charset=utf-8\r\n"
-> "Content-Length: 80\r\n"
-> "Connection: close\r\n"
-> "Set-Cookie: __cfduid=d605d1dcf202d00e60fc7822285fb15751544175109; expires=Sat, 07-Dec-19 09:31:49 GMT; path=/; domain=.hubapi.com; HttpOnly\r\n"
-> "Vary: Accept-Encoding\r\n"
-> "Access-Control-Allow-Credentials: false\r\n"
-> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n"
-> "Expect-CT: max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"\r\n"
-> "Server: cloudflare\r\n"
-> "CF-RAY: 4855fb3f9e9a4451-BRU\r\n"
-> "\r\n"
reading 80 bytes...
-> "{\"status\":\"error\",\"message\":\"must specify probability when writing a dealstage\"}"
read 80 bytes
Conn close
=> {"status"=>"error", "message"=>"must specify probability when writing a dealstage"}

probability is not in the documentation, but ok let's try it...

2 - Create a deal pipeline with probability in stages

<- "POST /crm-pipelines/v1/pipelines/deals HTTP/1.1\r\nAuthorization: Bearer CLfoocr4LBICQQEYrsy-AiCY3ukCKOSQCzIZAP4E6-cKglIuOPwS8awnMzzAOyCKHwYaKjoPAAoCRwAADIADAAgAAAABQhkA_gTr55tGOVFXBz16a4wwsE1OF3Y1M7xa\r\nContent-Type: application/json\r\nConnection: close\r\nHost: api.hubapi.com\r\nContent-Length: 292\r\n\r\n"
<- "{\"pipelineId\":\"api_test_pipeline\",\"label\":\"API test pipeline\",\"displayOrder\":1,\"active\":true,\"stages\":[{\"stageId\":\"example_stage\",\"label\":\"Example stage\",\"probability\":0.1,\"displayOrder\":1},{\"stageId\":\"another_example_stage\",\"label\":\"Another example stage\",\"probability\":1,\"displayOrder\":2}]}"
-> "HTTP/1.1 400 Bad Request\r\n"
-> "Date: Fri, 07 Dec 2018 09:34:16 GMT\r\n"
-> "Content-Type: application/json;charset=utf-8\r\n"
-> "Content-Length: 80\r\n"
-> "Connection: close\r\n"
-> "Set-Cookie: __cfduid=da7f1aafd726ef9a5e877a45b585a365f1544175256; expires=Sat, 07-Dec-19 09:34:16 GMT; path=/; domain=.hubapi.com; HttpOnly\r\n"
-> "Vary: Accept-Encoding\r\n"
-> "Access-Control-Allow-Credentials: false\r\n"
-> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n"
-> "Expect-CT: max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"\r\n"
-> "Server: cloudflare\r\n"
-> "CF-RAY: 4855fed99d72445d-BRU\r\n"
-> "\r\n"
reading 80 bytes...
-> "{\"status\":\"error\",\"message\":\"must specify probability when writing a dealstage\"}"
read 80 bytes
Conn close
=> {"status"=>"error", "message"=>"must specify probability when writing a dealstage"}

Same error !

3 - Creating a deal pipeline with the Deprecated API (It works...) (https://developers.hubspot.com/docs/methods/deal-pipelines/create-deal-pipeline)

<- "POST /deals/v1/pipelines HTTP/1.1\r\nAuthorization: Bearer CLfoocr4LBICQQEYrsy-AiCY3ukCKOSQCzIZAP4E6-cKglIuOPwS8awnMzzAOyCKHwYaKjoPAAoCRwAADIADAAgAAAABQhkA_gTr55tGOVFXBz16a4wwsE1OF3Y1M7xa\r\nContent-Type: application/json\r\nConnection: close\r\nHost: api.hubapi.com\r\nContent-Length: 245\r\n\r\n"
<- "{\"label\":\"API test pipeline\",\"displayOrder\":1,\"stages\":[{\"stageId\":\"example_stage\",\"label\":\"Example stage\",\"probability\":0.1,\"displayOrder\":1},{\"stageId\":\"another_example_stage\",\"label\":\"Another example stage\",\"probability\":1,\"displayOrder\":2}]}"
-> "HTTP/1.1 200 OK\r\n"
-> "Date: Fri, 07 Dec 2018 09:38:34 GMT\r\n"
-> "Content-Type: application/json;charset=utf-8\r\n"
-> "Transfer-Encoding: chunked\r\n"
-> "Connection: close\r\n"
-> "Set-Cookie: __cfduid=d8c662b8abd00d973b15f95fe74d4b98a1544175514; expires=Sat, 07-Dec-19 09:38:34 GMT; path=/; domain=.hubapi.com; HttpOnly\r\n"
-> "X-Trace: 2BFD4E79F9F489B9CD4C7BD041BAA21EB058D5DEBD000000000000000000\r\n"
-> "Access-Control-Allow-Credentials: false\r\n"
-> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n"
-> "Expect-CT: max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"\r\n"
-> "Server: cloudflare\r\n"
-> "CF-RAY: 485605261e17443f-BRU\r\n"
-> "\r\n"
-> "18e\r\n"
reading 398 bytes...
-> "{\"pipelineId\":\"1d296ef9-5755-48a7-99d7-829362b62a24\",\"stages\":[{\"stageId\":\"example_stage\",\"label\":\"Example stage\",\"probability\":0.1,\"active\":true,\"displayOrder\":1,\"closedWon\":false},{\"stageId\":\"another_example_stage\",\"label\":\"Another example stage\",\"probability\":1.0,\"active\":true,\"displayOrder\":2,\"closedWon\":true}],\"label\":\"API test pipeline\",\"active\":true,\"displayOrder\":1,\"staticDefault\":false}"
read 398 bytes
reading 2 bytes...
-> "\r\n"
read 2 bytes
-> "0\r\n"
-> "\r\n"
Conn close
=> {"pipelineId"=>"1d296ef9-5755-48a7-99d7-829362b62a24",
 "stages"=>
  [{"stageId"=>"example_stage", "label"=>"Example stage", "probability"=>0.1, "active"=>true, "displayOrder"=>1, "closedWon"=>false},
   {"stageId"=>"another_example_stage", "label"=>"Another example stage", "probability"=>1.0, "active"=>true, "displayOrder"=>2, "closedWon"=>true}],
 "label"=>"API test pipeline",
 "active"=>true,
 "displayOrder"=>1,
 "staticDefault"=>false}

4 - Updating a deal pipeline (it works... but crash the UI and API)

<- "PUT /crm-pipelines/v1/pipelines/deals/1d296ef9-5755-48a7-99d7-829362b62a24 HTTP/1.1\r\nAuthorization: Bearer CLfoocr4LBICQQEYrsy-AiCY3ukCKOSQCzIZAP4E6-cKglIuOPwS8awnMzzAOyCKHwYaKjoPAAoCRwAADIADAAgAAAABQhkA_gTr55tGOVFXBz16a4wwsE1OF3Y1M7xa\r\nContent-Type: application/json\r\nConnection: close\r\nHost: api.hubapi.com\r\nContent-Length: 275\r\n\r\n"
<- "{\"label\":\"API test pipeline updated\",\"displayOrder\":1,\"active\":true,\"stages\":[{\"stageId\":\"example_stage_two\",\"label\":\"Example stage two\",\"probability\":0.1,\"displayOrder\":1},{\"stageId\":\"another_example_stage\",\"label\":\"Another example stage\",\"probability\":1,\"displayOrder\":2}]}"
-> "HTTP/1.1 200 OK\r\n"
-> "Date: Fri, 07 Dec 2018 09:46:17 GMT\r\n"
-> "Content-Type: application/json;charset=utf-8\r\n"
-> "Content-Length: 508\r\n"
-> "Connection: close\r\n"
-> "Set-Cookie: __cfduid=d8a4bb83e16d9c154a755e3b2131d4eac1544175976; expires=Sat, 07-Dec-19 09:46:16 GMT; path=/; domain=.hubapi.com; HttpOnly\r\n"
-> "Vary: Accept-Encoding\r\n"
-> "Access-Control-Allow-Credentials: false\r\n"
-> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n"
-> "Expect-CT: max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"\r\n"
-> "Server: cloudflare\r\n"
-> "CF-RAY: 485610703ba24439-BRU\r\n"
-> "\r\n"
reading 508 bytes...
-> "{\"pipelineId\":\"1d296ef9-5755-48a7-99d7-829362b62a24\",\"createdAt\":1544175514630,\"updatedAt\":1544175977085,\"objectType\":\"DEAL\",\"label\":\"API test pipeline updated\",\"displayOrder\":1,\"active\":true,\"stages\":[{\"stageId\":\"another_example_stage\",\"createdAt\":0,\"updatedAt\":1544175977085,\"label\":\"Another example stage\",\"displayOrder\":2,\"metadata\":{},\"active\":true},{\"stageId\":\"example_stage_two\",\"createdAt\":0,\"updatedAt\":null,\"label\":\"Example stage     two\",\"displayOrder\":1,\"metadata\":{},\"active\":true}],\"default\":false}"
read 508 bytes
Conn close
=> {"pipelineId"=>"1d296ef9-5755-48a7-99d7-829362b62a24",
 "createdAt"=>1544175514630,
 "updatedAt"=>1544175977085,
 "objectType"=>"DEAL",
 "label"=>"API test pipeline updated",
 "displayOrder"=>1,
 "active"=>true,
 "stages"=>
  [{"stageId"=>"another_example_stage",
    "createdAt"=>0,
    "updatedAt"=>1544175977085,
    "label"=>"Another example stage",
    "displayOrder"=>2,
    "metadata"=>{},
    "active"=>true},
   {"stageId"=>"example_stage_two", "createdAt"=>0, "updatedAt"=>nil, "label"=>"Example stage two", "displayOrder"=>1, "metadata"=>{}, "active"=>true}],
 "default"=>false}

5 - UI is now broken (500 error)

6 - Get all deals pipelines API call is now broken (500 error)

 <- "GET /crm-pipelines/v1/pipelines/deals HTTP/1.1\r\nAuthorization: Bearer CLfoocr4LBICQQEYrsy-AiCY3ukCKOSQCzIZAP4E6-cKglIuOPwS8awnMzzAOyCKHwYaKjoPAAoCRwAADIADAAgAAAABQhkA_gTr55tGOVFXBz16a4wwsE1OF3Y1M7xa\r\nContent-Type: application/json\r\nConnection: close\r\nHost: api.hubapi.com\r\n\r\n"
 -> "HTTP/1.1 500 Internal Server Error\r\n"
 -> "Date: Fri, 07 Dec 2018 09:51:35 GMT\r\n"
 -> "Content-Type: application/json;charset=utf-8\r\n"
 -> "Content-Length: 45\r\n"
 -> "Connection: close\r\n"
 -> "Set-Cookie: __cfduid=d49af3a691691de32295821fe4566ecfe1544176295; expires=Sat, 07-Dec-19 09:51:35 GMT; path=/; domain=.hubapi.com; HttpOnly\r\n"
 -> "Vary: Accept-Encoding\r\n"
 -> "Access-Control-Allow-Credentials: false\r\n"
 -> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n"
 -> "Expect-CT: max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"\r\n"
 -> "Server: cloudflare\r\n"
 -> "CF-RAY: 48561838984d446f-BRU\r\n"
 -> "\r\n"
 reading 45 bytes...
 -> "{\"status\":\"error\",\"message\":\"internal error\"}"
 read 45 bytes
 Conn close
 => {"status"=>"error", "message"=>"internal error"}

Can you please fix all of this and get back in touch with me ?

Regards

0 Upvotes
1 Accepted solution
cbarley
Solution
HubSpot Alumni
HubSpot Alumni

Manipulating Deals pipelines via API is broken

SOLVE

Hi @reprtoir, our developers were able to get your Deals page back into the right state. Moving forward do not use the deprecated endpoint. The documentation has been updated for creating pipelines in the link I linked above, so you should be set to move forward with that endpoint.

View solution in original post

0 Upvotes
4 Replies 4
cbarley
Solution
HubSpot Alumni
HubSpot Alumni

Manipulating Deals pipelines via API is broken

SOLVE

Hi @reprtoir, our developers were able to get your Deals page back into the right state. Moving forward do not use the deprecated endpoint. The documentation has been updated for creating pipelines in the link I linked above, so you should be set to move forward with that endpoint.

0 Upvotes
reprtoir
Member

Manipulating Deals pipelines via API is broken

SOLVE

Hi @Connor_Barley

Thanks for the updated documentation, I'll give this a try tomorrow.

0 Upvotes
reprtoir
Member

Manipulating Deals pipelines via API is broken

SOLVE

Alright, everything is now working. I've been able to list, create and update a deal pipeline.

Thanks

cbarley
HubSpot Alumni
HubSpot Alumni

Manipulating Deals pipelines via API is broken

SOLVE

Hi @reprtoir, happy to help here. I've reached out to our product team to get your Deals page unstuck. I do have to say that this is our fault. What happened was that we had validation that was not strict enough, and if a new required parameter for Deals was not included in the payload, the deals page would get stuck. We fixed the new CRM pipelines endpoint's validation, but were testing and did not update the docs in time. See this thread:

We've since updated the docs: https://developers.hubspot.com/docs/methods/pipelines/create_new_pipeline

I understand the pain this has caused. Frankly, this is unacceptable and we'll use this to learn moving forward. That said, please refrain from using the deprecated endpoint moving forward. If you include the probability field within the metadata object moving forward all should be well.

0 Upvotes