I need to send to a webservice a PUT command
The following request was created using PAW on a Macintosh and worked.
----
PUT /PagoInReteWS/rest/pianodeicontiservice/crea HTTP/1.1
Authorization: Basic <base64 user and password>
Content-Type: application/json; charset=utf-8
Host: collaudo.pubblica.istruzione.it
Connection: close
User-Agent: Paw/3.1.10 (Macintosh; OS X/10.13.6) GCDHTTPRequest
Content-Length: 307
{"codiceDebole":"XXX","annoScolastico":XXXX,"flusso":"P3","fornitore":"XXXX","versioneSw":"XXXX","user":"XXXX","theListPianoDeiConti":[{"annoFinanziario":2020,"codiceScuola":"XXXXX","aggregato":"09","voce":"09","sottovoce":"01","descrizioneConto":"Alienazione di impianti prova"}]}
-------
I'm not able to replicate the command using tsNet library with tsNetCustomSync or tsNetCustom. Maybe i should use some other command ?
Thanks
Marco Puppo
How to make a PUT command [Solved]
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 9
- Joined: Tue Sep 07, 2010 6:49 pm
How to make a PUT command [Solved]
Last edited by marcopuppo on Thu Jun 18, 2020 11:40 am, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 7230
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: How to make a PUT command
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 190
- Joined: Sat Apr 08, 2006 7:55 am
- Location: Lübbecke, Germany
- Contact:
Re: How to make a PUT command
Marco,
it´s difficult to say what is going wrong, if you do not post a sample of your code.
I am no expert in webservices, but tsNetCustomUploadSync or tsNetCustomUpload should do
This is for tsNEtCustomUploadSync
tsNetCustomUploadSync(pURL, pRequest, xHeaders, pData, rOutHeaders, rResult, rBytes, [pSettings])
pURL contains the server URL
pRequest contains the request like put/delete or patch or whatever
xHeaders - see dictionary
pData contains the data you want to send (put) to the web service
rOutHeaders - will contain the headers that were returned from the server on completion.
rResult - will contain the status code sent by the server to the last command that was issued during the transfer.
rBytes - will contain the number of bytes that were downloaded/transfered during the connection
pSettings - is an array. see dictionary and the explanations below.
Your connection seems to need basic authentication. So you should set at least the username and password in pSettings:
put YOURUSERNAME into pSettings["username"]
put YOURPASSWORD into pSettings["password"]
tsNET normally should be able to detect the authentication method, but you could force tsNET to use basic authentication right away
put TRUE into pSettings["force_basic_auth"]
and a last one..
For testing i am using also
put TRUE into pSettings["no_reuse"]
This forces tsNET to close the connection to the server after the execution. If not set, tsNET leaves the connection open to the server for future connections. Especially when testing it might be good to let tsNET closing the connection after the command was executed.
As written already, i am not very firm with web services, but maybe the above lines are a good start for you.
HTH
Regards,
Matthias
it´s difficult to say what is going wrong, if you do not post a sample of your code.
I am no expert in webservices, but tsNetCustomUploadSync or tsNetCustomUpload should do
This is for tsNEtCustomUploadSync
tsNetCustomUploadSync(pURL, pRequest, xHeaders, pData, rOutHeaders, rResult, rBytes, [pSettings])
pURL contains the server URL
pRequest contains the request like put/delete or patch or whatever
xHeaders - see dictionary
pData contains the data you want to send (put) to the web service
rOutHeaders - will contain the headers that were returned from the server on completion.
rResult - will contain the status code sent by the server to the last command that was issued during the transfer.
rBytes - will contain the number of bytes that were downloaded/transfered during the connection
pSettings - is an array. see dictionary and the explanations below.
Your connection seems to need basic authentication. So you should set at least the username and password in pSettings:
put YOURUSERNAME into pSettings["username"]
put YOURPASSWORD into pSettings["password"]
tsNET normally should be able to detect the authentication method, but you could force tsNET to use basic authentication right away
put TRUE into pSettings["force_basic_auth"]
and a last one..
For testing i am using also
put TRUE into pSettings["no_reuse"]
This forces tsNET to close the connection to the server after the execution. If not set, tsNET leaves the connection open to the server for future connections. Especially when testing it might be good to let tsNET closing the connection after the command was executed.
As written already, i am not very firm with web services, but maybe the above lines are a good start for you.
HTH
Regards,
Matthias
Re: How to make a PUT command
Regarding PUT I found a message from Charles (the creator of tsNet) :
"You can use the tsNetCustom* functions to issue any HTTP(S) request type you require (including PATCH and PUT). The tsNetUpload* functions are also effectively just a PUT request when using the HTTP(S) protocols."
So I guess, this is the command you're looking for.
I wish we have a comprehensive set of real examples for each tsNet command.
We have this :
https://www.techstrategies.com.au/tsnet ... reference/
It's a start.
The library is rich, full of parameters (look at version 1.4 !)...
Personally I use only tsNetPostSync (for regular POST). But with a proper set of examples/guidelines, I would probably try other things.
"You can use the tsNetCustom* functions to issue any HTTP(S) request type you require (including PATCH and PUT). The tsNetUpload* functions are also effectively just a PUT request when using the HTTP(S) protocols."
So I guess, this is the command you're looking for.
I wish we have a comprehensive set of real examples for each tsNet command.
We have this :
https://www.techstrategies.com.au/tsnet ... reference/
It's a start.
The library is rich, full of parameters (look at version 1.4 !)...
Personally I use only tsNetPostSync (for regular POST). But with a proper set of examples/guidelines, I would probably try other things.
-
- VIP Livecode Opensource Backer
- Posts: 9
- Joined: Tue Sep 07, 2010 6:49 pm
Re: How to make a PUT command
Thank you for yor help, i will try on monday.
On late saturday and on sunday the server is not working.
In italy government server follow office rules. Not open on holidays.
Thank you
Marco
On late saturday and on sunday the server is not working.
In italy government server follow office rules. Not open on holidays.
Thank you
Marco
-
- VIP Livecode Opensource Backer
- Posts: 9
- Joined: Tue Sep 07, 2010 6:49 pm
Re: How to make a PUT command
It worked with tsNetCustomUploadSync.
Thank you very much.
Marco
Thank you very much.
Marco