Update a Deal Pipeline (PUT request)

deals

#1

Hi Everyone,

Just trying to use API to change the pipeline in HubSpot.

I keep getting an error using this API put call: $data = '{
"pipelineId": "default",
"stages": [
{
"stageId": "49fafda2-f166-4650-956a-1dc5f5514357",
"label": "Initial Qualification",
"probability": 0.1,
"active": true,
"displayOrder": 0,
"closedWon": false
},
{
"stageId": "customclosedwonstage",
"label": "Success! Closed Won",
"probability": 1,
"active": true,
"displayOrder": 1,
"closedWon": true
},
{
"label": "A new dealstage",
"probability": 1,
"active": true,
"displayOrder": 2,
"closedWon": true
},
{
"stageId": "newcustomdealstage",
"label": "Another new dealstage",
"probability": 1,
"active": true,
"displayOrder": 3,
"closedWon": true
}
],
"label": "New Custom Business Pipeline",
"active": true,
"displayOrder": 10
}
';

$ch = curl_init('http://api.hubapi.com/deals/v1/pipelines/default?hapikey=eda09c2e-2029-49bd-b8d9-XXXX');
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$res = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
var_dump($res, $error);

error: string(34) "Recv failure: Connection was reset"

Api call doesn’t change anything in my pipeline. However, it is supposed to change the pipeline stage.

I used this example: https://developers.hubspot.com/docs/methods/deal-pipelines/update-deal-pipeline
This doesn’t work as well.

Anybody knows why this is happening or how to do it right?

Thanks,

Geri


#3

Hi @geri1985, happy to help here! Can you reply with your HubID so I can take a closer look at this and try to reproduce the issue you're seeing? Make sure the pipelineID is correct in your call. Are you able to reproduce this in a REST client like Postman?


#4

Hi Connor,

My HubID is 5038421.

Many thanks,

Geri


#5

Sorry, didn't use Postman for this one but can do it there easily if you want. Please let me know if you need this.

Thanks


#6

Hi @geri1985, thanks for that! I actually noticed that the endpoint you're using is deprecated. You should instead use this endpoint: https://developers.hubspot.com/docs/methods/pipelines/udpate_pipeline.

Also, in your original post, you included your API key. Please refrain from posting sensitive information like this in the forums since these are public. I'd recommend deactivating your API key and generating a new one.


#7

Hi @Connor_Barley, thanks for your answers, but when I send a PUT request, then if you go to link: https://app.hubspot.com/contacts/5038421/deals/list/view/all/? the page does not load anything (screenshot attached)


CRM Pipeline API broke portal page
#8

Hi @geri1985, that's strange. I'm also able to reproduce the issue. I'm going to reach out to my team about this and get back to you when I have an answer.


#9

Thank you, Connor. I'm looking forward to hearing back from you soon.


#10

Hi @geri1985, just a quick update here. The team believes that the PUT request that you made may have deleted or altered it in a way that broke the Deal homepage. They're working on a fix at the moment.


#11

Hi @geri1985, our CRM developers just pushed out a fix for this. We're working on stronger validation that wouldn't allow your Deals page to get into that state in the first place, but you should be good to go moving forward.


#12

Thanks for this @Connor_Barley .

Yes, that worked. However, when I add new data or try something else with PUT request I keep getting the same error with broken Deals page and it's not loading.
Request:
POST: https://api.hubapi.com/crm-pipelines/v1/pipelines/deals?hapikey=XXXXXXXX-144f-45a3-aae3-865a454bfffc
Body: {
"pipelineId": "api_test_pipeline4",
"label": "API test deals pipeline",
"displayOrder": 3,
"active": true,
"stages": [
{
"label": "Initial Qualification",
"displayOrder": 0,
"probability": 0.1
},
{
"label": "Negotiation",
"displayOrder": 1,
"probability": 0.5
},
{
"label": "Success",
"displayOrder": 2,
"stageId": "customclosedwonstag",
"probability": 1
}
]
}

How long do you think will it take to do a stronger validation? Is there anything I can help with?

Thank you


#14

Hi @geri1985, taking a look at your POST data to create a new pipeline, I can see you have a probability field included which doesn't appear in the docs here. I can also see your displayOrder field starts at 0, when it should start at 1. That said, I was able to actually break my own deals page with a simple POST request based off of the docs. I'm in touch with the CRM team right now and will update when we've addressed the issue.


#15

Hi @geri1985, the team has added additional validation when creating/updating dealstages that will reject writes that don't include a probability. You should include the probability in all future requests. We'll update the docs to match tomorrow. Your account has been "unstuck" from the consistently loading Deals screen as well.


#16

Thanks @Connor_Barley. Requests for tickets pipelines do work now indeed. However, Deals keep returning an error : {
"status": "error",
"message": "must specify probability when writing a dealstage"
}
POST:

https://api.hubapi.com/crm-pipelines/v1/pipelines/deals?hapikey=********ac6c-50d5f0b9170b

{
"pipelineId": "api_test_pipelineMS",
"label": "API test deals pipeline",
"displayOrder": 3,
"active": true,

"stages": [
{
"label": "Initial Qualification",
"displayOrder": 1,
"probability": 0.1
},
{
"label": "Negotiation",
"displayOrder": 2,
"probability": 0.5
},
{
"label": "Success",
"displayOrder": 3,
"stageId": "customclosedwonstag",
"probability": 1
}
]
}


#17

Hey @geri1985, we're about to update the documentation, but your request should be formatted like this:

{
  "pipelineId": "pipeline_test",
  "label": "API test ticket pipeline",
  "displayOrder": 1,
  "active": true,
  "stages": [
    {
      "label": "Initial Qualification",
      "displayOrder": 1,
      "metadata":
      {
        "probability": 0.1
      }
      },
    {
      "label": "Negotiation",
      "displayOrder": 1,
      "metadata":
      {
        "probability": 0.5
      }
    }
  ]
}

probability should be in a metadata object


Manipulating Deals pipelines via API is broken