Archicad C++ API
About Archicad add-on development using the C++ API.

[SLVD] Prefered way to make a http request and parse xml doc

Miha Nahtigal
Advocate
I've noticed that there is a XML engine included with AC Api in GSRoot module.

Unfortunately there are no examples nor is it mentioned in the documentation. Is it just undocumented section or are there any examples for us to use?

Secondly, is there a preferred "AC API" way to execute a http request from a plugin? An example would be great too.
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.
8 REPLIES 8
Anonymous
Not applicable
Hey Vuego,

I don't have an answer for you, I'm just joining this thread because I'd like to know how to make HTTP requests. HTTPS requests would be even better.
Mihaly Palenik
Graphisoft
Graphisoft
Hello,
vuego wrote:
I've noticed that there is a XML engine included with AC Api in GSRoot module.

There is more than one XML Engine which you can use. For what purpose would you like to use it?
vuego wrote:
Secondly, is there a preferred "AC API" way to execute a http request from a plugin? An example would be great too.

You can find examples about http/https request in API DevKit's Examples/Goodie_Functions/Src/Goodie_Functions.cpp.
One of them is Do_DownloadWebpage function.

Best,
Mihály
Miha Nahtigal
Advocate
Thanks Mihály for pointing me in the right direction.

Besides Do_DownloadWebpage, there are also Do_XML_From_String() and Do_XML_Write(), that are all I needed.
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.
Miha Nahtigal
Advocate
I have another question. I am getting binary data with my http request into GS::IChannelX. My binary data is a gsm object.

Response response;
	GS::IChannelX channel(clientConnection.BeginReceive(response), GS::GetNetworkByteOrderIProtocolX());
I would like to store binary response to a file object IO::File..

	IO::Location rab("C:/GDLTest/11204.gsm2");
	IO::File targetFile(rab, IO::File::Create);
How can I store data from GS::ChanelX into IO::File?
Or, is it possible to use IO::File as IChannel and store request directly to file using clientConnection.BeginReceive(response) ?

Thank you in advance.
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.
Akos Somorjai
Graphisoft
Graphisoft
vuego wrote:
I have another question. I am getting binary data with my http request into GS::IChannelX. My binary data is a gsm object.


How can I store data from GS::ChanelX into IO::File?
Or, is it possible to use IO::File as IChannel and store request directly to file using clientConnection.BeginReceive(response) ?

Thank you in advance.
The 'I' in IChannel stands for input channel. You have to open an output channel (GS::OChannel), which can be an IO::File, then write the data directly into it.

Best, Akos
Miha Nahtigal
Advocate
Sorry, I ment IO::File as output channel.

I am having trouble receiving/writing data from HTTP::ClientConnection directly into IO::File (GS::OChannel)... how do I achieve that?
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.
Akos Somorjai
Graphisoft
Graphisoft
vuego wrote:
Sorry, I ment IO::File as output channel.

I am having trouble receiving/writing data from HTTP::ClientConnection directly into IO::File (GS::OChannel)... how do I achieve that?
Again: IChannels are for input OChannel are for output. The http connection is the input channel, and you yourself have to write that information to the output channel (== IO::File). So the pseudo code:

read bytes from input
write bytes to output

Best, Akos
Miha Nahtigal
Advocate
Ok, Akos, thanks.

I thought there would be a more elegant way of connecting input and output channels than that
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!