<?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: Need Restful API functionality in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246791#M3028</link>
    <description>Has anyone else worked with the JSON parsing in the ArchiCAD API? I am facing a similar problem to Bianca's example above.&lt;BR /&gt;
&lt;BR /&gt;
I can get the response data as text no worries, but cannot seem to get a member string value cast to GS::UniString.</description>
    <pubDate>Wed, 19 Aug 2020 07:56:56 GMT</pubDate>
    <dc:creator>Danny Sparks-Cousins</dc:creator>
    <dc:date>2020-08-19T07:56:56Z</dc:date>
    <item>
      <title>Need Restful API functionality</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246789#M3026</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi&lt;BR /&gt;I noticed that there are header files for HTTP and JSON. Does Archicad 22 have the ability to do Restful calls?&lt;BR /&gt;I have tried, with no luck, to get 3rd party Casablanca HTTP library to work in a project.&lt;BR /&gt;Please help&lt;BR /&gt;&lt;BR /&gt;Archicad 22 &lt;BR /&gt;Windows&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 Sep 2022 08:19:32 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246789#M3026</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-29T08:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need Restful API functionality</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246790#M3027</link>
      <description>Ok I have found examples in Goodies example project.  Now having a problem with Casting to Json object, throws an exception.  I am able to retreive the response data as text but I really need a JSON object&lt;BR /&gt;
&lt;BR /&gt;
/* throws exception at GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(parsed); */&lt;BR /&gt;
DBPrintf("HTTP %u\n", response.GetStatusCode());&lt;BR /&gt;
	if (response.GetStatusCode() == StatusCode::OK) {&lt;BR /&gt;
		&lt;BR /&gt;
		JSON::ObjectValueRef object = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(parsed);&lt;BR /&gt;
		JSON::StringValueRef tokenValue = GS::DynamicCast&amp;lt;JSON::StringValue&amp;gt;(object-&amp;gt;Get("regionName"));&lt;BR /&gt;
		if (tokenValue != nullptr) {&lt;BR /&gt;
			GS::UniString token = tokenValue-&amp;gt;Get();&lt;BR /&gt;
			DBPrintf("NBS Token: %s\n", token.ToCStr().Get());&lt;BR /&gt;
		}&lt;BR /&gt;
	}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
	&lt;BR /&gt;
	/* Working but text only */&lt;BR /&gt;
	SAJParser saxParser;&lt;BR /&gt;
	ExampleSAJParseTracer testSAXParseTracer;&lt;BR /&gt;
&lt;BR /&gt;
	saxParser.Parse(clientConnection.BeginReceive(response), testSAXParseTracer);&lt;BR /&gt;
	if (testSAXParseTracer.ParseFinished()) {&lt;BR /&gt;
		DBPrintf("The content of the JSON file was:\n%s\n", testSAXParseTracer.GetOutput().ToCStr(0, MaxUSize, CC_UTF8).Get());&lt;BR /&gt;
	}&lt;BR /&gt;
&lt;BR /&gt;
	clientConnection.FinishReceive();&lt;BR /&gt;
	clientConnection.Close(false);&lt;BR /&gt;
&lt;BR /&gt;
	}&lt;BR /&gt;
	catch ( std::exception&amp;amp;)&lt;BR /&gt;
	{&lt;BR /&gt;
		std::string error;&lt;BR /&gt;
	}</description>
      <pubDate>Wed, 07 Aug 2019 05:12:19 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246790#M3027</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-07T05:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need Restful API functionality</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246791#M3028</link>
      <description>Has anyone else worked with the JSON parsing in the ArchiCAD API? I am facing a similar problem to Bianca's example above.&lt;BR /&gt;
&lt;BR /&gt;
I can get the response data as text no worries, but cannot seem to get a member string value cast to GS::UniString.</description>
      <pubDate>Wed, 19 Aug 2020 07:56:56 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246791#M3028</guid>
      <dc:creator>Danny Sparks-Cousins</dc:creator>
      <dc:date>2020-08-19T07:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need Restful API functionality</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246792#M3029</link>
      <description>Use a JSON::JDOMParser to parse the client's response into a JSON object:&lt;BR /&gt;
&lt;BR /&gt;
HTTP::Client::Response response;&lt;BR /&gt;
JSON::JDOMParser parser;&lt;BR /&gt;
JSON::ValueRef parsed = parser.Parse(client-&amp;gt;BeginReceive(response));&lt;BR /&gt;
&lt;BR /&gt;
// check statuscode&lt;BR /&gt;
auto statusCode = response.GetStatusCode();&lt;BR /&gt;
&lt;BR /&gt;
if (statusCode == HTTP::MessageHeader::StatusCode::OK) {&lt;BR /&gt;
    JSON::ObjectValueRef object = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(parsed);&lt;BR /&gt;
    // do whatever you need with 'object'&lt;BR /&gt;
}</description>
      <pubDate>Fri, 18 Sep 2020 07:57:38 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246792#M3029</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-18T07:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Need Restful API functionality</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246793#M3030</link>
      <description>&lt;BLOCKQUOTE&gt;Kengey wrote:&lt;BR /&gt;
Use a JSON::JDOMParser to parse the client's response into a JSON object:&lt;BR /&gt;
&lt;BR /&gt;
HTTP::Client::Response response;&lt;BR /&gt;
JSON::JDOMParser parser;&lt;BR /&gt;
JSON::ValueRef parsed = parser.Parse(client-&amp;gt;BeginReceive(response));&lt;BR /&gt;
&lt;BR /&gt;
// check statuscode&lt;BR /&gt;
auto statusCode = response.GetStatusCode();&lt;BR /&gt;
&lt;BR /&gt;
if (statusCode == HTTP::MessageHeader::StatusCode::OK) {&lt;BR /&gt;
    JSON::ObjectValueRef object = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(parsed);&lt;BR /&gt;
    // do whatever you need with 'object'&lt;BR /&gt;
}
&lt;/BLOCKQUOTE&gt;
Can you please write some code after "//do whatever you want", like how to get values from the object?</description>
      <pubDate>Wed, 16 Jun 2021 08:22:50 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246793#M3030</guid>
      <dc:creator>Mihalcea Bogdan</dc:creator>
      <dc:date>2021-06-16T08:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need Restful API functionality</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246794#M3031</link>
      <description>I found another parser here.&lt;BR /&gt;
C:\Program Files\GRAPHISOFT\API Development Kit 24.3009\Support\Modules\RapidJSON&lt;BR /&gt;
&lt;A href="https://github.com/Tencent/rapidjson" target="_blank"&gt;Documentation for rapidJSON&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
It gave me better results and the code is much more readable.</description>
      <pubDate>Thu, 17 Jun 2021 14:31:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Need-Restful-API-functionality/m-p/246794#M3031</guid>
      <dc:creator>Mihalcea Bogdan</dc:creator>
      <dc:date>2021-06-17T14:31:46Z</dc:date>
    </item>
  </channel>
</rss>

