APIs & Integrations

victorclee
Member

Internal error when updating user by vid

SOLVE

Hi!

Got an internal error response when trying to post to Contacts API with user vid.

{"status"=>"error", "message"=>"internal error", "correlationId"=>"882e4799-b484-453b-b066-5ceb12979f62", "requestId"=>"7ce9fe5842ea340f2d6f38a26b074795"}

Can someone help me, and what other information can I provide on here to solve the issue?

Thanks,
Victor

0 Upvotes
1 Accepted solution
victorclee
Solution
Member

Internal error when updating user by vid

SOLVE

@Isaac_Takushi

The issue was solved by not using Unirest to make the HTTP call.

I ended up using URI and Net::HTTP.

I also added a .to_json at the end of my request body request.body = data.to_json

Finally got a 204!

Thanks for your help!

View solution in original post

0 Upvotes
17 Replies 17
IsaacTakushi
HubSpot Employee
HubSpot Employee

Internal error when updating user by vid

SOLVE

I'm glad to hear it, @victorclee!

I was thinking the issue was with the body data's format, since the payload you pasted above is in Hash rather than JSON. I guess the .to_json method didn't work in Unirest?

Isaac Takushi

Associate Certification Manager
0 Upvotes
victorclee
Member

Internal error when updating user by vid

SOLVE

@Isaac_Takushi

I think Unirest understands the to_json method, since it's documented in their readme.

http://unirest.io/ruby.html
Under the "Custom Entity Body" section

At this point, I'm not able to pinpoint what the issue was with Unirest. The success came from an effort to duplicate what is working from using Postman, and the libraries it used were URI and Net::HTTP

0 Upvotes
victorclee
Member

Internal error when updating user by vid

SOLVE

@Isaac_Takushi Could it be something in the header?

0 Upvotes
victorclee
Solution
Member

Internal error when updating user by vid

SOLVE

@Isaac_Takushi

The issue was solved by not using Unirest to make the HTTP call.

I ended up using URI and Net::HTTP.

I also added a .to_json at the end of my request body request.body = data.to_json

Finally got a 204!

Thanks for your help!

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Internal error when updating user by vid

SOLVE

@victorclee,

I'm frankly not familiar with Ruby, so you know more than I do on that front. Is there any way you can get me the actual JSON request body sent to the endpoint? (Not the Hash or the code you're entering in the app.)

I'm heading out for the day, but I'll see what I can do tomorrrow.

Isaac Takushi

Associate Certification Manager
0 Upvotes
victorclee
Member

Internal error when updating user by vid

SOLVE

@Isaac_Takushi sure thing. Here's the actual data that's in the payload.

{:properties=>[{:property=>"causes", :value=>"Animals & Environment, Youth & Education"}, {:property=>"charities_helped", :value=>"8"}, {:property=>"dollars_donated", :value=>"75.0"}, {:property=>"percents", :value=>"1.0"}, {:property=>"referral_code", :value=>"https://www.percentpledge.org/invite?ref=Um1HUQ"}, {:property=>"referrees", :value=>"1"}, {:property=>"billable", :value=>"true"}]}

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Internal error when updating user by vid

SOLVE

Hi @victorclee,

Unirest seems to want a Hash for parameters and you're currently calling .to_json on a JSON object.

Can you try:

{:properties=>[{:property=>"firstname", :value=>"Avacado"}]}

Failing that, try:

{:properties=>[{:property=>"firstname", :value=>"Avacado"}]}.to_json

P.S. I've removed your API key since this is a public forum.

Isaac Takushi

Associate Certification Manager
0 Upvotes
victorclee
Member

Internal error when updating user by vid

SOLVE

@Isaac_Takushi, thanks for responding! Still got 500 status back on both attempts. And yes, thank you very much for catching that for me :slight_smile:

What are some other solutions we can try?

0 Upvotes
victorclee
Member

Internal error when updating user by vid

SOLVE

Happy Monday, @Isaac_Takushi! Does the code example above help give you any insights on where the formatting issue is?

Hi @dadams , I was reading up on some other forum posts regarding developers getting 500 status code and saw your name several times. Please excuse me for roping you in in the middle, but thought the more set of eyes and brains on an issue the better. I provided most of the info I can in earlier posts. Please let me know what other info I can provide to give you a better picture of the issue. Thanks!

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Internal error when updating user by vid

SOLVE

Hey @victorclee,

I was able to update your contact's Would you like to see some puppies? property, so the HubSpot endpoint and your API key are working properly.

I unfortunately won't be of much help in troubleshooting Rails, but in this case, the 500 error suggests some formatting issue to me.

Are you able to get an example of the actual call made (not with the variables but the actual vid injected?

Isaac Takushi

Associate Certification Manager
0 Upvotes
victorclee
Member

Internal error when updating user by vid

SOLVE

@Isaac_Takushi

Here's an code example of an attempt to update my own HubSpot contact through the API

require 'unirest'
require 'json'

contact = Unirest.post "https://api.hubapi.com/contacts/v1/contact/vid/2367/profile?hapikey=KEY", 
                        headers: { "Accept" => "application/json" }, 
                        parameters: {"properties": [{"property": "firstname", "value": "Avocado"}]}.to_json
 
puts contact.code

contact.code shows me 500, and there's no update to my profile.

0 Upvotes
victorclee
Member

Internal error when updating user by vid

SOLVE

Any updates would be appreciated, @Isaac_Takushi

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Internal error when updating user by vid

SOLVE

Hey @victorclee,

I thought you were trying to update a contact by its vid? That endpoint is via email.

Would you share a link to a contact you are attempting to update via the vid endpoint?

Isaac Takushi

Associate Certification Manager
0 Upvotes
victorclee
Member

Internal error when updating user by vid

SOLVE

@Isaac_Takushi

Sorry, posted the wrong url. I've tried updating both via email and vid, but I always get the 500 response.

"https://api.hubapi.com/contacts/v1/contact/vid/#{ @user.hubspot_vid }/profile?hapikey=#{ Rails.application.secrets.hubspot_api_key }"

I was trying to update myself as a test

https://app.hubspot.com/contacts/4592187/contact/2367/?interaction=note

0 Upvotes
victorclee
Member

Internal error when updating user by vid

SOLVE

I'm integrating the Contacts API with our Rails app, and I'm using a gem called Unirest to make the call

http://unirest.io/ruby.html

I can make changes to myself through the API when using Postman, but always get 500 response through our Rails app

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Internal error when updating user by vid

SOLVE

Hi @victorclee,

Happy to help. To troubleshoot effectively, though, I'll need the following information:

  1. Your Hub ID.
  2. The full request URL you used, including the method. (Don't include your API key.)
  3. The raw request body, including the headers.
  4. The status code you received from HubSpot.

Isaac Takushi

Associate Certification Manager
0 Upvotes
victorclee
Member

Internal error when updating user by vid

SOLVE

@Isaac_Takushi

  1. 4592187
  2. post https://api.hubapi.com/contacts/v1/contact/email/#{ @user.email }/profile?hapikey=#{Rails.application.secrets.hubspot_api_key}

headers:{ "Accept" => "application/json" },
parameters:{
"properties": [
{
"property": "causes",
"value": "#{ @user.active_causes }"
},
{
"property": "charities_helped",
"value": "#{ charities_count }"
},
{
"property": "dollars_donated",
"value": "#{ total_giving }"
},
{
"property": "percents",
"value": "#{ percent_pledged }"
},
{
"property": "referral_code",
"value": "#{ set_share_link }"
},
{
"property": "referrees",
"value": "#{ @user.referrees.count }"
},
{
"property": "billable",
"value": "#{ @user.billable? }"
},
{
"property": "firstname",
"value": "Avocado"
}
]
}

  1. code: 500
    {"status"=>"error", "message"=>"internal error", "correlationId"=>"5c172128-03c4-4329-987a-dc41b8e6cc27", "requestId"=>"1fe81a449aaac48704d95b2837dacd68"}
0 Upvotes