<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Updating Contact Property Authorization Issue in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Updating-Contact-Property-Authorization-Issue/m-p/954141#M80246</link>
    <description>&lt;P&gt;Hey, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/505816"&gt;@Mrafey&lt;/a&gt;&lt;/SPAN&gt; &lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Thanks for your post. I have a couple of questions:&lt;/P&gt;
&lt;UL&gt;
 &lt;LI&gt;have you tried sending this request &lt;STRONG&gt;without&lt;/STRONG&gt; the mode: 'no-cors'?&amp;nbsp;&lt;/LI&gt;
 &lt;LI&gt;have you tried sending the same request via Postman? If so, does it work without giving an error?&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Thanks! — Jaycee&lt;/P&gt;</description>
    <pubDate>Wed, 03 Apr 2024 16:47:27 GMT</pubDate>
    <dc:creator>Jaycee_Lewis</dc:creator>
    <dc:date>2024-04-03T16:47:27Z</dc:date>
    <item>
      <title>Updating Contact Property Authorization Issue</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Updating-Contact-Property-Authorization-Issue/m-p/953581#M80245</link>
      <description>&lt;P&gt;Hello all!&lt;BR /&gt;&lt;BR /&gt;I am getting a 401 unauthorized issue when trying to hit the following endpoint:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A href="https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/:email/" target="_blank" rel="noopener"&gt;https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/:email/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I have provided a authorization header within my fetch request in my code and I still get a unauthorized error when making the POST request.&lt;BR /&gt;&lt;BR /&gt;Here is my code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// HubSpot form submit event to store endangered animal result value into contact property
window.addEventListener('message', e =&amp;gt; {
	if(event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormSubmit' &amp;amp;&amp;amp; event.origin === document.location.origin) {
	
    let email = $("input[name=email]").val()
		
		updateContactProperty(animal, email);
		
	}
})

async function updateContactProperty(animal, email) {
const token = "my_app_token"
const data = {
	"properties": [
		{
			"property": "endangered_animal_quiz_result",
			"value": animal
		}
	]
}	

// 	make request to endpoint
	const res = await fetch(`https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/${email}/`, {
		mode: 'no-cors',
		method: 'post',
		headers: new Headers({
			'Authorization': `Bearer ${token}`,
			'content-type': "application/json"
		}),
		body: JSON.stringify(data)
	})

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Would anyone have any idea what I may be doing wrong?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 20:49:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Updating-Contact-Property-Authorization-Issue/m-p/953581#M80245</guid>
      <dc:creator>Mrafey</dc:creator>
      <dc:date>2024-04-02T20:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Contact Property Authorization Issue</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Updating-Contact-Property-Authorization-Issue/m-p/954141#M80246</link>
      <description>&lt;P&gt;Hey, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/505816"&gt;@Mrafey&lt;/a&gt;&lt;/SPAN&gt; &lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Thanks for your post. I have a couple of questions:&lt;/P&gt;
&lt;UL&gt;
 &lt;LI&gt;have you tried sending this request &lt;STRONG&gt;without&lt;/STRONG&gt; the mode: 'no-cors'?&amp;nbsp;&lt;/LI&gt;
 &lt;LI&gt;have you tried sending the same request via Postman? If so, does it work without giving an error?&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Thanks! — Jaycee&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 16:47:27 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Updating-Contact-Property-Authorization-Issue/m-p/954141#M80246</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2024-04-03T16:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Contact Property Authorization Issue</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Updating-Contact-Property-Authorization-Issue/m-p/954198#M80247</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074"&gt;@Jaycee_Lewis&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;When not specifying the mode to 'no-cors' I end up getting a cors policy issue stating the following &lt;STRONG&gt;"has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource."&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;As for testing it on postman. The request works just as intended which is why I am confused why it doesn't work with the code I have in the Design Manager.&lt;BR /&gt;&lt;BR /&gt;Here is my postman setup...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following screenshot is showing the post request url, payload that I am sending which is updating the property &lt;STRONG&gt;"endangered_animal_quiz_result"&lt;/STRONG&gt;, followed by the result at the bottom which is a 200 response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2024-04-03 at 1.40.39 PM.png" style="width: 661px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/114436i2E116F1793CA0F3D/image-dimensions/661x298?v=v2" width="661" height="298" role="button" title="Screen Shot 2024-04-03 at 1.40.39 PM.png" alt="Screen Shot 2024-04-03 at 1.40.39 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is the authorization setup. I have removed my actual token value for obvious reasons, but here is the authentication which I have set to Bearer Token type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2024-04-03 at 1.42.29 PM.png" style="width: 659px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/114437iD5B04E0B9E8209B1/image-dimensions/659x111?v=v2" width="659" height="111" role="button" title="Screen Shot 2024-04-03 at 1.42.29 PM.png" alt="Screen Shot 2024-04-03 at 1.42.29 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Works on postman, I have tested it a few times. But for some odd reason the code I have in my Design Manager for the module throws a 401 error....&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 17:45:18 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Updating-Contact-Property-Authorization-Issue/m-p/954198#M80247</guid>
      <dc:creator>Mrafey</dc:creator>
      <dc:date>2024-04-03T17:45:18Z</dc:date>
    </item>
  </channel>
</rss>

