<?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 Send file in multipart-form POST request in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Send-file-in-multipart-form-POST-request/m-p/375559#M789</link>
    <description>&lt;P&gt;I want to send a .xlsx file to the server using Restful POST request in a multipart-form data. I am able to send normal text in POST body, but how do i send a file. I am using&amp;nbsp;Communication::Client::Http::HttpClientRequest as shown in CommunicationClient_test example in SDK.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2023 09:39:44 GMT</pubDate>
    <dc:creator>Ankur Yadav</dc:creator>
    <dc:date>2023-04-05T09:39:44Z</dc:date>
    <item>
      <title>Send file in multipart-form POST request</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Send-file-in-multipart-form-POST-request/m-p/375559#M789</link>
      <description>&lt;P&gt;I want to send a .xlsx file to the server using Restful POST request in a multipart-form data. I am able to send normal text in POST body, but how do i send a file. I am using&amp;nbsp;Communication::Client::Http::HttpClientRequest as shown in CommunicationClient_test example in SDK.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 09:39:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Send-file-in-multipart-form-POST-request/m-p/375559#M789</guid>
      <dc:creator>Ankur Yadav</dc:creator>
      <dc:date>2023-04-05T09:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Send file in multipart-form POST request</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Send-file-in-multipart-form-POST-request/m-p/571133#M8729</link>
      <description>&lt;P&gt;Hi Ankur,&amp;nbsp;&lt;BR /&gt;I was able to get response from the call with status 200, but not able to parse the response using the code below&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;using namespace HTTP::Client;
	using namespace HTTP::MessageHeader;
	using namespace GS::IBinaryChannelUtilities;

	IO::URI::URI connectionUrl ("https://identity.thenbs.com/");
	ClientConnection clientConnection (connectionUrl);
	clientConnection.Connect ();

	Request postRequest (Method::Post, "/core/connect/token");

	GS::UniString clientID = "user";
	GS::UniString clientSecret = "pass";
	// More information on the API, and on getting an API key:
	// https://toolkit.thenbs.com/articles/for-software-developers/#bimToolkitAPI

	RequestHeaderFieldCollection&amp;amp; headers = postRequest.GetRequestHeaderFieldCollection ();
	Authentication::BasicAuthentication auth (clientID, clientSecret);
	auth.HandleRequestHeaderFieldCollection (headers);
	headers.Add (HeaderFieldName::ContentType, "application/x-www-form-urlencoded");

	GS::UniString postBody = "scope=bimtoolkitapi&amp;amp;grant_type=client_credentials";
	clientConnection.Send (postRequest, postBody.ToCStr (), postBody.GetLength ());

	Response response;
	JSON::JDOMParser parser;
	JSON::ValueRef parsed = parser.Parse (clientConnection.BeginReceive (response));

	DBPrintf ("HTTP %u\n", response.GetStatusCode ());
	if (response.GetStatusCode () == StatusCode::OK) {
		JSON::ObjectValueRef object = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt; (parsed);
		JSON::StringValueRef tokenValue = GS::DynamicCast&amp;lt;JSON::StringValue&amp;gt; (object-&amp;gt;Get ("access_token"));
		if (tokenValue != nullptr) {
			GS::UniString token = tokenValue-&amp;gt;Get ();
			DBPrintf ("NBS Token: %s\n", token.ToCStr ().Get ());
		}
	}

	clientConnection.FinishReceive ();
	clientConnection.Close (false);&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Could you help on this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 06:31:24 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Send-file-in-multipart-form-POST-request/m-p/571133#M8729</guid>
      <dc:creator>roni</dc:creator>
      <dc:date>2023-10-17T06:31:24Z</dc:date>
    </item>
  </channel>
</rss>

