Welcome! Log In Create A New Profile

Advanced

[WX12] HTTP PUT and HTTP DELETE methods via httpRequest()

Posted by Peter Holemans 
Peter Holemans
[WX12] HTTP PUT and HTTP DELETE methods via httpRequest()
September 02, 2008 03:50PM
Hi,

Back from holidays and I finaly am getting the Google Calendar integration to work (logon, creation of events on other persons calendars, retrieving calendars and events, etc...). Now, I need to also be able to update/delete Google Calendar events based on triggers in my app. This requires HTTP PUT and HTTP DELETE method calls. I have the impression that the WX httpRequest() command only supports HTTP POST and HTTP GET methods. Is that correct? If so, has any of you found a workaround to this big limitation?

Thank you for your feedback!

Cheers,
Hi,

Looking into the http protocol and the Google API's I found a way to override the http method using a simple POST statement (and thus using the httpRequest() command).
It requires an additional header (which is possible as the third parameter of the httpRequest() command and which I already use to provide an additional authentication header).
The syntax is like this: X-HTTP-Method-Override: PUT
However, I can't seem to get it to work using httpRequest() since it always times out if I add this additional header. Any guru's out there that can help me out?

Cheers,

Peter H.
Hi Peter,

In the help, on HTTPRequest, there is a section at the bottom explaining how to PUT informations with the function (I have the French help). Did you take a look at it and gave it a try?

HTTPRequest("url",*,*,"FIELD1=Value"+CR+"FIELD2=Value"+CR+"submit")

Regards.
Hi Alexandre,

Thank you for your feedback. This might be an option, but I am not submitting a form (with fields) but an XML request (other content-type) so this doesn't seem to be an option. However, I'll have a closer look later today.

Cheers,

Peter
Hi Guys,

Have you solved that problem with submitting XML file. I have already same problem. I need to create small script which can create XML file and after that submit to other server API.

Tell me please httpRequest() is going to work or should I use something different?

Thanks

David
It works but it took me a lot of headaches...
Here's a sample call that should get you going:
(Note global member URL_GCAL_CONT_TYPE_ADD = "application/atom+xml" and URL_GCAL_REQUEST_AGENT = "Mozilla/4.0 (compatible; MSIE 6.0; Winrdows NT 5.0)")
...blablabla previous code in Method FUNCTION gCal_AddEvent(lint_CoworkerID is int = 0)
	//Set URL
	lstr_gCalendarURL = StringBuild(::URL_GCAL_REQUEST,:str_gCalAccount)
	lstr_GCalendarAUTHHeader = StringBuild(::URL_GCAL_REQUEST_AUTH_HEADER,:str_gCalLoginAUTH)
	//Build XML Message
	//%1 = Title or subject
	//%2 = Body
	//%3 = Location
	//%4 = Startdate yyyy-mm-dd	%5 = Starttime HH:MMconfused smileyS:CCC
	//%6 = Enddate yyyy-mm-dd	%7 = Endtime HH:MMconfused smileyS:CCC
	//%8 = Reminder days
	lstr_XMLBody = StringBuild(:angry smileyML_GCAL_ADD_EVENT, TextToXML(MeetingRequest.Subject), TextToXML(MeetingRequest.Notes), TextToXML(MeetingRequest.Location), ...
	TextToXML(DateToString(MeetingRequest.MeetingDate,"AAAA-MM-JJ")),TextToXML(TimeToString(MeetingRequest.StartTime,"HH:MMconfused smileyS")), ...
	TextToXML(DateToString(MeetingRequest.MeetingDate,"AAAA-MM-JJ")),TextToXML(TimeToString(MeetingRequest.EndTime,"HH:MMconfused smileyS")),"1440")
	//Convert to UTF8 
	lstr_XMLBodyAsUTF8 = StringToUTF8(lstr_XMLBody)
	IF lstr_XMLBodyAsUTF8 <> EOT THEN
		lstr_XMLBody = lstr_XMLBodyAsUTF8
	END
	//Send HTTP Request
	IF HTTPRequest(lstr_gCalendarURL,::URL_GCAL_REQUEST_AGENT,lstr_GCalendarAUTHHeader,lstr_XMLBody,::URL_GCAL_CONT_TYPE_ADD) THEN
		//Get reply
		lstr_gCalHeaderReply = HTTPGetResult(HTTPHeader)
		lstr_gCalDetailReply = HTTPGetResult(HTTPResult)
		//	200 OK No Error. 
		//	201 CREATED Creation of A resource was successful. 
		//	304 NOT MODIFIED The resource hasn't changed since the time specified IN the request's IF-Modified-Since header. 
		//	400 BAD REQUEST Invalid request URI OR header, OR unsupported nonstandard parameter. 
		//	401 UNAUTHORIZED Authorization required. 
		//	403 FORBIDDEN Unsupported standard parameter, OR authentication OR authorization failed. 
		//	404 NOT FOUND Resource (such as A feed OR entry) NOT found. 
		//	409 CONFLICT Specified version number doesn't match resource's latest version number. 
		//	500 INTERNAL SERVER Error Internal Error. This is the Default code that is used FOR ALL unrecognized errors.
...blablabla next code in method
And now... as of version 14, all Google apps are natively integrated into W-Language using Gglxxx commands... This could have saved me lots of time...
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: