API Create Deal Call failing when calling from application.

I am calling hubspot api POST https://api.hubapi.com/deals/v1/deal?hapikey=demo

to create a deal from a api client insomnia with following as the body of json

{
	"properties": [
		{
			"value": "John Doe Test Deal",
			"name": "dealname"
		},
		{
			"value": "1294558",
			"name": "pipeline"
		},
		{
			"value": "2500000",
			"name": "amount"
		},
		{
			"value": "1294560",
			"name": "dealstage"
		}
	]
}

but when i do the same with a firebase cloud function to the hubspot api i get an error saying that

[{"isValid":false,"message":"1294559 is not a valid pipeline stage ID. Valid options are: pipelineId=default : [appointmentscheduled, qualifiedtobuy, presentationscheduled, decisionmakerboughtin, contractsent]","error":"INVALID_OPTION","name":"dealstage"}],"status":"error","message":"Property values were not valid"

Hi @siddharth-cm,

It looks like the issue lies with the values you are passing in for the `pipeline` and `dealstage` attributes. I would recommend making a GET request to the CRM pipelines endpoint to pull down the data for the deal pipeline in that portal. The response will contain the “pipelineId” and the “stageId” values which you can use in your POST request to create a deal. For example when I run:

GET https://api.hubapi.com/crm-pipelines/v1/pipelines/deals?hapikey={{apikey}}

It returns the following payload. Look at the values for “pipelineId” and “stageId”. These should be used in your POST request to create the deal.

{
 "results": [
 {
 "pipelineId": "default",
 "objectType": "DEAL",
 "label": "Sales Pipeline",
 "active": true,
 "stages": [
 {
 "stageId": "presentationscheduled"
 },
 {
 "stageId": "decisionmakerboughtin"
 },
 {
 "stageId": "appointmentscheduled"
 },
 {
 "stageId": "contractsent"
 },
 {
 "stageId": "qualifiedtobuy"
 },
 {
 "stageId": "closedwon"
 },
 {
 "stageId": "closedlost"
 }
 ],
 "default": true
 }
 ]
}

With the data above I can create a deal using the following endpoint:

POST https://api.hubapi.com/deals/v1/deal?hapikey={{apikey}}

{
	"properties": [
		{
			"value": "John Doe Test Deal",
			"name": "dealname"
		},
		{
			"value": "default",
			"name": "pipeline"
		},
		{
			"value": "2500000",
			"name": "amount"
		},
		{
			"value": "presentationscheduled",
			"name": "dealstage"
		}
	]
}

I hope this helps.

Jack

Thank you @jackcoldrick ,

Just asking,

In my case I am getting unique numbers as pipeline stage id.Is it a special case or exception in one way or another.

Thanks again.

Hi @siddharth-cm,

If you are using the “default” pipeline included with the portal the deal stages will be returned as string values as shown in my example. However if it’s an additional pipeline you created then it’s expected the “stageId” would be a random string of numbers.

Does this help?

Regards,

Jack

Thanks

This was helpful
16x16_smiley-happy.png.png

Hi

I am having the same problem. When I try to call the API to create a ticket from the python sample on Accounts Dashboard | HubSpot with the following code

{
“hs_pipeline”: “default”,
“hs_pipeline_stage”: “decisionmakerboughtin”,

“hs_ticket_priority”: “HIGH”,
“hubspot_owner_id”: “284345313”,
“subject”: “troubleshoot report”
}

I am getting this error

HTTP 400

{
“status”: “error”,
“message”: “Property values were not valid: [{\“isValid\”:false,\“message\”:\“decisionmakerboughtin is not a valid pipeline stage ID. Valid options are: pipelineId=0 : [1, 2, 3, 4]\”,\“error\”:\“INVALID_OPTION\”,\“name\”:\“hs_pipeline_stage\”}]”,
“correlationId”: “1e6fe089-8c07-410c-a168-480a453bdf9c”,
“category”: “VALIDATION_ERROR”
}

I have called https://api.hubapi.com/crm-pipelines/v1/pipelines/deals?hapikey=xxxxx and I am getting this respose which shows that the stage does exist. Another thing is that I have edited that pipeline and on the web it shows what I have enterd but the API returns the original codes