Hi Frank,
Calling HTTP endpoints from FoxPro is fairly straight forward. There are several libraries out there that provide that through WinInet or WinHttp. West Wind has the wwHttp class (as part of West Wind Client Tools) which makes HTTP calls super easy, including the file uploads mentioned in your API and ability to use all HTTP verbs for requests.
The West Wind Client Tools also include a wwJsonSerializer class that can parse just about any type of JSON into a FoxPro object. It uses a popular .NET JSON parser behind the scenes so it's very capable in terms of what it can deal with (unlike my own and some other FoxPro based implementations which are slow somewhat unreliable with very complex JSON).
wwHttp Class Reference:
wwHttp ClassSome Http Examples:
Basic Http AccessUploading Files:
Http File UploadswwJsonSerializer Class Reference:
wwJsonSerializerHoller if you have questions - it's usually quicker if you hit our
West Wind Message Board - but I check here on occasion as well.
+++ Rick ---
>Hi,
>
>I have been asked to use a restful API (I believe that's what it's called to retrieve and post files to a folder on the web - or in the cloud as is the common term now).
>
>How do I do this from VFP?
>
>I have been given the following information:
>
>Viewing:
>
>To view a document simply go to the following URL. It will output a pdf file.
>
>
http://***.***.***.***/api/index.php/documents/index/>
>Example of a live document:
>
>
http://***.***.***.***/api/index.php/documents/index/8CF8797D-4FDF-7A4C-3750-4C8BFF1A4BC4>
>Uploading:
>
>To upload a file you have to do a HTTP POST to this URL:
>
>
http://***.***.***.***/api/index.php/claims/upload>
>It expects 2 parameters:
>
>doc_pk - the primary key for the field in the ClaimDocuments table which holds the description etc on the document
>pdf - this should be a base64 encoded string of the contents of the file to upload
>
>This is a sample of the code I use to upload a document:
>
>$response = $this->rest->post('claims/upload', array(
>'doc_pk'=> $doc_pk,
>'pdf' => base64_encode(file_get_contents('resources/img/doctors.jpg'))
>), 'json');
>
>As you can see I first read the contents of the file, then encode it, then send it to the RESTful server.
>
>The server will return a response in JSON. This is the php dump of that response:
>
>stdClass Object
>(
>[error] => false
>[message] => File uploaded successfully.
>)
>
>The error variable will be true or false. The message will correspond to the error state.
>
>To force an error you can POST to the URL with no variables.