Creating Deal from API for Custom Pipeline


#1

Hi,
I am trying to create a deal for a contact in a custom pipeline for a custom dealstage.

While dealstageid is correct and linked to the pipeline, the validation says the contrary:

{“status”:“error”,“message”:“Property values were not valid”,“correlationId”:“05629922-fec8-42ef-b86c-b1fc1f9db4e7”,“validationResults”:[{“isValid”:false,“message”:"Dealstage (485b8338-f5b6-4855-9b0b-0ab1175c3ba5) must exist within specified pipeline (Automated).

While i have this in the response that confirms the link between the dealstage and the pipeline:
{“pipelineId”:“25eb64d3-79ba-461e-bf0f-0943b3d9ff94”,“stages”:[{“stageId”:“485b8338-f5b6-4855-9b0b-0ab1175c3ba5”,“label”:“Trial Created 1”,“probability”:0.1,“active”:true,“displayOrder”:0,“closedWon”:false}],“label”:“Automated”,“active”:true,“displayOrder”:5},

Can you help me on this.

Thank you for your time,
Stéphane


#2

@sdehousse can you share with me the body of your call? You might have an issue there.


#3

Here is my python method.
Thank you for your support
`
def create_deal(contact_id):
print(“create new deal”)
post_createDeal_url = “https://api.hubapi.com/deals/v1/deal?hapikey=
”+hapikey

    #485b8338-f5b6-4855-9b0b-0ab1175c3ba5
    #Trial Created 1
    deal_property = {
    "associations":{"associatedVids":[contact_id]},
    "portalId":portalId,
    "properties":[
    {"value":"485b8338-f5b6-4855-9b0b-0ab1175c3ba5","name":"dealstage"},
    {"value": "Automated","name": "pipeline"},
    {"value": "AUTOGENERATED","name": "dealname"}
    ]
    }

    r = requests.post(post_createDeal_url, json=deal_property)

    response = json.loads(r.text)

    if(response["status"]=="error"):
    print(response["message"])
    print(r.text)
    else:
    print("Success")

`


#4

@sdehousse If you made a call to get all the deal stages of the pipeline can you print here the results? I want to make sure you stageID to the pipeline you have actually exists in you Automated pipeline


#5

Here you are.

{"pipelineId":"25eb64d3-79ba-461e-bf0f-0943b3d9ff94","stages":[{"stageId":"485b8338-f5b6-4855-9b0b-0ab1175c3ba5","label":"Trial Created 1","probability":0.1,"active":true,"displayOrder":0,"closedWon":false}],"label":"Automated","active":true,"displayOrder":5}


#6

@sdehousse are you sending over the data with the header defining the content type as application/json? I have seen in the past where we have thrown errors because it cannot correctly parse the json.


#7

Yes. As you can see my call “request.post” uses param json which generates the header.

This code is working when i target a default pipeline and one of its dealstage.
I think the issue is related to the fact that i am targeting a “custom pipeline”.


#8

@sdehousse Ok cool, I am a little lost as to why this giving you trouble. I have a coupe thoughts

Could you try with the pipeline ID instead of the label?

Any chance you can capture the actual call you make? You have shown me your code, which looks correct but I can’t see for sure the actual call that gets generated and made.


#9

Here is what i am sending

-----------START-----------

POST https://api.hubapi.com/deals/v1/deal?hapikey=xxx
Content-Length: 249
Content-Type: application/json

{“associations”: {“associatedVids”: [7228605]}, “portalId”: “437856”, “properties”: [{“name”: “dealstage”, “value”: “c38aa505-6629-4397-8f71-dc28615c2038”}, {“name”: “pipeline”, “value”: “Automated”}, {“name”: “dealname”, “value”: “AUTOGENERATED”}]}


#10

Goodnews ! Using the pipeline id solved the issue.

Thank you for your support,
Stéphane


#11

Sorry for the delayed response. I’m glad you got it figured out. Let me know if you run into anything else.