# Internal error when updating user by vid

**URL:** <https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [October 9, 2018, 5:48pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890 "2018-10-09T17:48:56Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 9, 2018, 5:48pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/1 "2018-10-09T17:48:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 10, 2018, 12:31pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/2 "2018-10-10T12:31:12Z")

</div>

Hi [@victorclee](https://community.hubspot.com/u/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.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 10, 2018, 7:32pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/3 "2018-10-10T19:32:57Z")

</div>

[@Isaac\_Takushi](https://community.hubspot.com/u/isaac_takushi)

1. 4592187
2. post [https://api.hubapi.com/contacts/v1/contact/email/#](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”}

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 10, 2018, 8:05pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/4 "2018-10-10T20:05:56Z")

</div>

Hey [@victorclee](https://community.hubspot.com/u/victorclee),

I thought you were trying to update a contact [by its vid](https://developers.hubspot.com/docs/methods/contacts/update_contact)? That endpoint is [via email](https://developers.hubspot.com/docs/methods/contacts/update_contact-by-email).

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

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 10, 2018, 8:11pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/5 "2018-10-10T20:11:17Z")

</div>

[@Isaac\_Takushi](https://community.hubspot.com/u/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/#](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

> **[HubSpot](https://app.hubspot.com/contacts/4592187/contact/2367/?interaction=note)**

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 10, 2018, 8:16pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/6 "2018-10-10T20:16:19Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 11, 2018, 6:07pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/7 "2018-10-11T18:07:53Z")

</div>

Any updates would be appreciated, [@Isaac\_Takushi](https://community.hubspot.com/u/isaac_takushi)

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 12, 2018, 4:43pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/8 "2018-10-12T16:43:27Z")

</div>

Hey [@victorclee](https://community.hubspot.com/u/victorclee),

I was able to update [your contact’s _Would you like to see some puppies?_ property](https://app.hubspot.com/contacts/4592187/contact/2367/properties?search=puppies), so the [HubSpot endpoint](https://developers.hubspot.com/docs/methods/contacts/update_contact) and [your API key](https://app.hubspot.com/integrations-beta/4592187/your-integrations/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?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 12, 2018, 6:02pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/9 "2018-10-12T18:02:48Z")

</div>

[@Isaac\_Takushi](https://community.hubspot.com/u/isaac_takushi)

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 15, 2018, 7:29pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/10 "2018-10-15T19:29:20Z")

</div>

Happy Monday, [@Isaac\_Takushi](https://community.hubspot.com/u/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!

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 15, 2018, 8:38pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/11 "2018-10-15T20:38:44Z")

</div>

Hi [@victorclee](https://community.hubspot.com/u/victorclee),

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

Can you try:

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

```

Failing that, try:

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

```

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

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 15, 2018, 8:48pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/12 "2018-10-15T20:48:43Z")

</div>

[@Isaac\_Takushi](https://community.hubspot.com/u/isaac_takushi), thanks for responding! Still got 500 status back on both attempts. And yes, thank you very much for catching that for me  
 ![slightly_smiling_face.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/2/42c4d129a1c6aa74d89f3066ee8fbb15db46b3b5.png)

What are some other solutions we can try?

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 15, 2018, 8:55pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/13 "2018-10-15T20:55:40Z")

</div>

[@victorclee](https://community.hubspot.com/u/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.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 16, 2018, 2:00am UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/14 "2018-10-16T02:00:13Z")

</div>

[@Isaac\_Takushi](https://community.hubspot.com/u/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"}]}`

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 16, 2018, 1:17pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/15 "2018-10-16T13:17:19Z")

</div>

[@Isaac\_Takushi](https://community.hubspot.com/u/isaac_takushi) Could it be something in the header?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 16, 2018, 4:55pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/16 "2018-10-16T16:55:39Z")

</div>

[@Isaac\_Takushi](https://community.hubspot.com/u/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!

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 16, 2018, 5:01pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/17 "2018-10-16T17:01:30Z")

</div>

I’m glad to hear it, [@victorclee](https://community.hubspot.com/u/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?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 16, 2018, 5:09pm UTC](https://community.hubspot.com/t/internal-error-when-updating-user-by-vid/11890/18 "2018-10-16T17:09:50Z")

</div>

[@Isaac\_Takushi](https://community.hubspot.com/u/isaac_takushi)

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

[http://unirest.io/ruby.html](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

[

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/f/2/f2fe658d26bd84e9c727302846f6fc154e4b1587.png)

Screen Shot 2018-10-16 at 12.08.54 PM.png719x580 35.2 KB

]([https://community.hubspot.com/legacyfs/online/uploads/default/original/2X/1/1446233159bc24577e958a45718bd237af399e04.png](https://community.hubspot.com/legacyfs/online/uploads/default/original/2X/1/1446233159bc24577e958a45718bd237af399e04.png))
