Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Restful API
Message
From
18/06/2013 07:37:49
 
General information
Forum:
Visual FoxPro
Category:
Internet applications
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01576581
Message ID:
01576602
Views:
60
Thanks, have you used either of these?

>See if http://www.sweetpotatosoftware.com/spsblog/2008/12/19/VisualFoxproJSONClassUpdate.aspx can be helpful
>Check also http://www.west-wind.com/WestwindClientTools.aspx
>
>>
>>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.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Reply
Map
View

Click here to load this message in the networking platform