<?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: Migrating from API key to Private App in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Migrating-from-API-key-to-Private-App/m-p/754622#M61340</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/518055"&gt;@LailaM&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your are right, sorry for wrong information&lt;/P&gt;
&lt;P&gt;&amp;gt;&lt;SPAN&gt;?idProperty=email&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested your new program, using api v3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works, using email registered in 'contact'.&lt;BR /&gt;But it is not works using email not in 'contact'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This case, response is this.&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;Array
(
    [status] =&amp;gt; error
    [message] =&amp;gt; resource not found
    [correlationId] =&amp;gt; ce12a676-c55e-4d6f-9764-9b62fbee265d
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So,&amp;nbsp; Is "test@gmail.com" registered in 'contact'?&lt;/P&gt;
&lt;P&gt;Or please test, another 'email' registered in 'contact'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2023 10:51:48 GMT</pubDate>
    <dc:creator>skimura</dc:creator>
    <dc:date>2023-02-10T10:51:48Z</dc:date>
    <item>
      <title>Migrating from API key to Private App</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Migrating-from-API-key-to-Private-App/m-p/753281#M61234</link>
      <description>&lt;P&gt;Could you assist me on API key migration.&lt;BR /&gt;I created the new Private app then tried to execute the code&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="markup"&gt;$access_token = "&amp;lt;access token&amp;gt;";
$email = "test@gmail.com";
$url = "https://api.hubapi.com/crm/v3/objects/contacts/".$email."?idProperty=email";
$headers = [
"Authorization: Bearer ".$access_token,
"Content-Type: application/json"
];
$post = array(
'properties' =&amp;gt; array(
'online_course_completion' =&amp;gt; 'YES'
),
);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "PATCH" );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $post ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status_code == 200) {
$response_json = json_decode($response, true);
print_r($response_json);
} else {
echo "Request failed with status code: ".$status_code;
}&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;but I'm always getting 404, and seing the response on hubspot log, it shows:&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="markup"&gt;{"status":"error","message":"resource not found","correlationId":"dec53aa7-8a2d-42b1-8c01-68724152cfa9"}&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;Here is the code that is working with the API key for reference:&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="markup"&gt;$url = 'https://api.hubapi.com/contacts/v1/contact/email/'.$email.'/profile?hapikey=' . $hubspot_api_key;

$post = array(
'properties' =&amp;gt; array(
array(
'property' =&amp;gt; 'online_course_completion',
'value' =&amp;gt; 'YES',
)
),
);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type:application/json' ) );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $post ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

$server_output = curl_exec( $ch );

curl_close( $ch );&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;Thank!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 09:33:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Migrating-from-API-key-to-Private-App/m-p/753281#M61234</guid>
      <dc:creator>LailaM</dc:creator>
      <dc:date>2023-02-09T09:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Migrating from API key to Private App</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Migrating-from-API-key-to-Private-App/m-p/753983#M61298</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/518055"&gt;@LailaM&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about this? (It use legacy api)&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;$url = 'https://api.hubapi.com/contacts/v1/contact/email/'.$email.'/profile?hapikey=' . $hubspot_api_key;

$post = [
  'properties' =&amp;gt; [
    'property' =&amp;gt; 'online_course_completion',
    'value' =&amp;gt; 'YES'
  ]
];

$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
$headers = [
  "Authorization: Bearer ".$access_token,
  "Content-Type: application/json"
];

// only change headers (add "Authorization")
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $post ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

$server_output = curl_exec( $ch );

curl_close( $ch );&lt;/LI-CODE&gt;
&lt;P&gt;When use legacy api, add header "Authorization: Bearer {TOKEN}".&lt;/P&gt;
&lt;P&gt;&lt;A href="https://legacydocs.hubspot.com/docs/methods/contacts/update_contact-by-email" target="_blank"&gt;https://legacydocs.hubspot.com/docs/methods/contacts/update_contact-by-email&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your new source code use hubspot api "v3".&lt;/P&gt;
&lt;P&gt;&amp;gt;$url = "&lt;A href="https://api.hubapi.com/crm/v3/objects/contacts/" target="_blank"&gt;https://api.hubapi.com/crm/v3/objects/contacts/&lt;/A&gt;".$email."?idProperty=email";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, this endpoint needs "contactId" instead of "email".&lt;/P&gt;
&lt;P&gt;I think that's the reason for the 404.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PATCH /crm/v3/objects/contacts/{contactId}&lt;/P&gt;
&lt;P&gt;&lt;A href="https://developers.hubspot.jp/docs/api/crm/contacts" target="_blank"&gt;https://developers.hubspot.jp/docs/api/crm/contacts&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 11:01:05 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Migrating-from-API-key-to-Private-App/m-p/753983#M61298</guid>
      <dc:creator>skimura</dc:creator>
      <dc:date>2023-02-09T11:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Migrating from API key to Private App</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Migrating-from-API-key-to-Private-App/m-p/754161#M61305</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is to get rid of the API key which is already deprecated and can be take down at any moment and replace it with the private app, so I can't use the API key anymore.&lt;/P&gt;&lt;P&gt;With private app, I have to use&amp;nbsp;hubspot api "v3" that's effectively&amp;nbsp;needs "contactId" instead of "email" but I've read here &lt;A href="https://developers.hubspot.com/docs/api/crm/contacts" target="_blank"&gt;https://developers.hubspot.com/docs/api/crm/contacts&lt;/A&gt; that you can give email as parameter if you add "?idProperty=email".&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Please note: the idProperty query parameter doesn't appear on the Endpoints tab due to technical limitations, but it can be used for contacts exclusively with email. To use an email address as the unique identifier, set the idProperty as email and enter the email address in place of the contact ID. This should be set as a query parameter rather than added to the request body.&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;My question is why it's not working with email as parameter?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 16:27:26 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Migrating-from-API-key-to-Private-App/m-p/754161#M61305</guid>
      <dc:creator>LailaM</dc:creator>
      <dc:date>2023-02-09T16:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Migrating from API key to Private App</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Migrating-from-API-key-to-Private-App/m-p/754622#M61340</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/518055"&gt;@LailaM&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your are right, sorry for wrong information&lt;/P&gt;
&lt;P&gt;&amp;gt;&lt;SPAN&gt;?idProperty=email&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested your new program, using api v3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works, using email registered in 'contact'.&lt;BR /&gt;But it is not works using email not in 'contact'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This case, response is this.&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;Array
(
    [status] =&amp;gt; error
    [message] =&amp;gt; resource not found
    [correlationId] =&amp;gt; ce12a676-c55e-4d6f-9764-9b62fbee265d
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So,&amp;nbsp; Is "test@gmail.com" registered in 'contact'?&lt;/P&gt;
&lt;P&gt;Or please test, another 'email' registered in 'contact'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 10:51:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Migrating-from-API-key-to-Private-App/m-p/754622#M61340</guid>
      <dc:creator>skimura</dc:creator>
      <dc:date>2023-02-10T10:51:48Z</dc:date>
    </item>
  </channel>
</rss>

