<?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 How to associate Task with Custom object? in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-associate-Task-with-Custom-object/m-p/1043040#M76741</link>
    <description>&lt;P&gt;I've to attach task with my custom object. I'm using below code as defined in docs. But I can't able to create it and my object name is 'test'.&lt;/P&gt;&lt;LI-CODE lang="php"&gt;I've created Association class in PHP:
Association::create($from, $to, $type, $fromObjectType, $toObjectType);

$from =&amp;gt; task_id
$to =&amp;gt; custom_object_id
$type =&amp;gt; I've custom object name test so I passed test_to_task
I don't have idea about $fromObjectType, $toObjectType.

Where create method contains below code:
public function create($from, $to, $type, $fromObjectType, $toObjectType)
    {
        $fromId = new PublicObjectId([
            'id' =&amp;gt; $from,
        ]);

        $toId = new PublicObjectId([
            'id' =&amp;gt; $to,
        ]);

        $publicAssociation1 = new PublicAssociation([
            'from' =&amp;gt; $fromId,
            'to' =&amp;gt; $toId,
            'type' =&amp;gt; $type,
        ]);

        $batchInputPublicAssociation = new BatchInputPublicAssociation([
            'inputs' =&amp;gt; [$publicAssociation1],
        ]);

        return $hubSpot-&amp;gt;crm()-&amp;gt;associations()-&amp;gt;batchApi()-&amp;gt;create($fromObjectType, $toObjectType, $batchInputPublicAssociation);
    }

Where $hubSpot is:
Factory::createWithAccessToken('access_token');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Sep 2024 07:56:03 GMT</pubDate>
    <dc:creator>KPadhiyar</dc:creator>
    <dc:date>2024-09-19T07:56:03Z</dc:date>
    <item>
      <title>How to associate Task with Custom object?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-associate-Task-with-Custom-object/m-p/1043040#M76741</link>
      <description>&lt;P&gt;I've to attach task with my custom object. I'm using below code as defined in docs. But I can't able to create it and my object name is 'test'.&lt;/P&gt;&lt;LI-CODE lang="php"&gt;I've created Association class in PHP:
Association::create($from, $to, $type, $fromObjectType, $toObjectType);

$from =&amp;gt; task_id
$to =&amp;gt; custom_object_id
$type =&amp;gt; I've custom object name test so I passed test_to_task
I don't have idea about $fromObjectType, $toObjectType.

Where create method contains below code:
public function create($from, $to, $type, $fromObjectType, $toObjectType)
    {
        $fromId = new PublicObjectId([
            'id' =&amp;gt; $from,
        ]);

        $toId = new PublicObjectId([
            'id' =&amp;gt; $to,
        ]);

        $publicAssociation1 = new PublicAssociation([
            'from' =&amp;gt; $fromId,
            'to' =&amp;gt; $toId,
            'type' =&amp;gt; $type,
        ]);

        $batchInputPublicAssociation = new BatchInputPublicAssociation([
            'inputs' =&amp;gt; [$publicAssociation1],
        ]);

        return $hubSpot-&amp;gt;crm()-&amp;gt;associations()-&amp;gt;batchApi()-&amp;gt;create($fromObjectType, $toObjectType, $batchInputPublicAssociation);
    }

Where $hubSpot is:
Factory::createWithAccessToken('access_token');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 07:56:03 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-associate-Task-with-Custom-object/m-p/1043040#M76741</guid>
      <dc:creator>KPadhiyar</dc:creator>
      <dc:date>2024-09-19T07:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to associate Task with Custom object?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-associate-Task-with-Custom-object/m-p/1043458#M76772</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/813499"&gt;@KPadhiyar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When making an API call to create an association, the fromObjectType should contain the internal name of the object, so 'contact' or 'company', the same goes for the toObjectType.&lt;BR /&gt;So in your case, you can use 'task' and 'test' for the two variables.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 20:43:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-associate-Task-with-Custom-object/m-p/1043458#M76772</guid>
      <dc:creator>Teun</dc:creator>
      <dc:date>2024-09-19T20:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to associate Task with Custom object?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-associate-Task-with-Custom-object/m-p/1043558#M76780</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/101258"&gt;@Teun&lt;/a&gt;, Thanks for the answer. I've done same thing before posting here. But its gives me error like:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[ 400] Client error: `POST &lt;A href="https://api.hubapi.com/crm/v3/associations/task/test/batch/create" target="_blank"&gt;https://api.hubapi.com/crm/v3/associations/task/test/batch/create&lt;/A&gt;` resulted in a ` 400 Bad Request` response:&lt;BR /&gt;{"status":"error","message":"Unable to infer object type from: test".&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I'm using below code:&lt;BR /&gt;Association::make($hubSpotAccount)-&amp;gt;create(&lt;BR /&gt;task_id,&lt;BR /&gt;test_object object_id,&lt;BR /&gt;"test_to_task",&lt;BR /&gt;"task",&lt;BR /&gt;"test"&lt;BR /&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 03:58:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-associate-Task-with-Custom-object/m-p/1043558#M76780</guid>
      <dc:creator>KPadhiyar</dc:creator>
      <dc:date>2024-09-20T03:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to associate Task with Custom object?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-associate-Task-with-Custom-object/m-p/1049541#M77079</link>
      <description>&lt;P&gt;I'm still finding solution for above.&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 09:27:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-associate-Task-with-Custom-object/m-p/1049541#M77079</guid>
      <dc:creator>KPadhiyar</dc:creator>
      <dc:date>2024-10-03T09:27:22Z</dc:date>
    </item>
  </channel>
</rss>

