RESTful PUT error

Pi Digital sean at pidigital.co.uk
Sun Nov 26 13:06:32 EST 2017


I’ve been working on a library connecting LiveCode with MS Dynamics365 CRM via some APIs custom made for us in c#. LiveCode makes its calls to the API by REST. At first I was using Put url to send some simple calls but started getting errors in some. I was advised to switch over to using Post instead of Put (which acts more like Get anyway). So I’d just use Post empty to url when no parameters were needed. Errors all gone. 

So my advice to you is use only Get and Post. 

tRequestURL1 = https://api.pipedrive.com/v1/persons?api_token=ef2c59a67144d185277fee92aa9ede877c6c10ff

tRequestURL2 = https://api.pipedrive.com/v1/persons/2?api_token=ef2c59a67144d185277fee92aa9ede877c6c10ff

tJSONtoUpload = {"phone":"555-555-5555"}

Post empty to url(tRequestURL1)
Put it into tResponse1

Post tJSONtoUpload to url(tRequestURL2)
Put it into tResponse2

Sean Cole
Pi Digital

> On 26 Nov 2017, at 16:07, Roger Eller via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> If I remember correctly, PUT was never implemented in LibUrl.  I have only
> needed GET and POST in my rather limited uses.
> 
> ~Roger
> 
> 
> On Nov 26, 2017 10:37 AM, "Andrew Bell via use-livecode" <
> use-livecode at lists.runrev.com> wrote:
> 
> I'm working on connecting to a 3rd-party API (Pipedrive) to a LiveCode app
> I've done and seem to have a problem; any assistance would be appreciated.
> Dummy (sandbox) account information has been included with my code sample.
> 
> I've never used RESTful before, but the API seems pretty well documented
> and I've had success much faster than anticipated working with the data in
> LiveCode. It looks like commands are broke down into 3 types: GET (to
> retrieve data), POST (to create new data), and PUT (to update existing
> data).
> 
> I can retrieve data using "put URL tRequestURL1 into tJSONfromPipedrive"
> I can create new data using "post tJSONtoUpload to url tRequestURL2"
> But when I try to update data using "put tJSONtoUpload into url
> tRequestURL2" I get a 400 error from the server. I tried to
> urlEncode(tJSONtoUpload) but got the same error.
> 
> Their API includes a sandbox for testing, and my code seems to align with
> their examples and helped me get my tests in order. I'm just not sure
> what's wrong with my PUT command. https://developers.pipedrive.c
> om/docs/api/v1/#!/Persons/put_persons_id
> 
> VARIABLE VALUES:
> httpHeaders = {"Accept":"application/json"}
> tRequestURL1 = https://api.pipedrive.com/v1/persons?api_token=ef2c59a67144d
> 185277fee92aa9ede877c6c10ff
> tRequestURL2 = https://api.pipedrive.com/v1/persons/2?api_token=ef2c59a6714
> 4d185277fee92aa9ede877c6c10ff
> tJSONtoUpload = {"phone":"555-555-5555"}
> 
> Is there something glaring I'm missing? I can get this to execute on their
> developer website, but using the same code seems to error out for me in
> LiveCode 8.2.0dp2 Business.
> 
> --Andrew Bell
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list