<?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: Find thing by Name from .NET SDK in ThingWorx Developers</title>
    <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Find-thing-by-Name-from-NET-SDK/m-p/623049#M38400</link>
    <description>&lt;P&gt;Hi &lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/297551"&gt;@AlessandroN&lt;/a&gt;.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;If the previous response answered your questions, please mark it as the Accepted Solution for the benefit of others with the same questions.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Regards.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;--Sharon&lt;/P&gt;</description>
    <pubDate>Tue, 20 Aug 2019 18:38:12 GMT</pubDate>
    <dc:creator>slangley</dc:creator>
    <dc:date>2019-08-20T18:38:12Z</dc:date>
    <item>
      <title>Find thing by Name from .NET SDK</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Find-thing-by-Name-from-NET-SDK/m-p/619589#M37743</link>
      <description>&lt;P&gt;Hi all, I'm trying to check if a thing exists before do other stuff.&lt;BR /&gt;Actually I'm taking the "long road", invoking the&amp;nbsp; SearchThingsByTemplate service, but it doesn't work as well, since seems that the "thingTemplate" is not accepted as String.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;(you can find the error log as attacched)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ValueCollection thingParams = new ValueCollection();
thingParams.Add("maxItems", new NumberPrimitive(500));
thingParams.Add("thingTemplate", new StringPrimitive(thingTemplate));
            
var infotable = client.invokeService(ThingworxEntityTypes.Resources, ,"SearchFunctions", "SearchThingsByTemplate", thingParams, 5000);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;QUESTIONS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- How can i give a "ThingTemplate" to this service?&lt;BR /&gt;- Can I check if a Thing exists in an other way?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 16:35:31 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Find-thing-by-Name-from-NET-SDK/m-p/619589#M37743</guid>
      <dc:creator>AlessandroN</dc:creator>
      <dc:date>2019-07-24T16:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Find thing by Name from .NET SDK</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Find-thing-by-Name-from-NET-SDK/m-p/621855#M38177</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/297551"&gt;@AlessandroN&lt;/a&gt;.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Unfortunately, the log file did not come through, but there is an example included in the .NET SDK download that may provide some guidance around your use case.&amp;nbsp; This example provides some alternative options to the approach you're using but may be helpful in determining the best design.&amp;nbsp; This &lt;A href="http://support.ptc.com/help/thingworx_edge_sdks_ems/wsems_545/en/#page/thingworx_edge_sdks_ems%2Fdotnet_sdk%2Fc_dotnet_sdk_section_introduction.html%23" target="_blank"&gt;page&lt;/A&gt; from the ThingWorx Help Center may also be helpful.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;For the Thing Template name, you would need to provide that at the time the Thing is created.&amp;nbsp; You can find more information &lt;A href="http://support.ptc.com/help/thingworx_edge_sdks_ems/wsems_545/en/#page/thingworx_edge_sdks_ems%2Fdotnet_sdk%2Fc_dotnet_sdk_getting_started_create_thing_thingworx_platform.html%23" target="_blank"&gt;here&lt;/A&gt;.&amp;nbsp; Here is an &lt;A href="https://www.ptc.com/en/support/article?n=CS212691" target="_blank"&gt;article&lt;/A&gt; that may also help.&amp;nbsp; Here is an example for creating a Thing:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-family:Courier New,Courier,monospace"&gt;ValueCollection param = new ValueCollection();&lt;BR /&gt;
_client.invokeService(com.thingworx.relationships.RelationshipTypes.ThingworxEntityTypes.Resources, "EntityServices", "CreateThing", param, 1000);&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The example above does not spell out all the parameters available for creating a Thing, but the parameters available are the same ones you would see in Composer when creating a Thing manually.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Would recommend implementing some try/catch logic to determine if the Thing exists, checking the error (if it already exists), and then adding the logic needed for the desired outcome.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Regards.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;--Sharon&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 15:02:16 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Find-thing-by-Name-from-NET-SDK/m-p/621855#M38177</guid>
      <dc:creator>slangley</dc:creator>
      <dc:date>2019-08-08T15:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Find thing by Name from .NET SDK</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Find-thing-by-Name-from-NET-SDK/m-p/623049#M38400</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/297551"&gt;@AlessandroN&lt;/a&gt;.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;If the previous response answered your questions, please mark it as the Accepted Solution for the benefit of others with the same questions.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Regards.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;--Sharon&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 18:38:12 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Find-thing-by-Name-from-NET-SDK/m-p/623049#M38400</guid>
      <dc:creator>slangley</dc:creator>
      <dc:date>2019-08-20T18:38:12Z</dc:date>
    </item>
  </channel>
</rss>

