POST versus PUT

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

POST versus PUT

Keith M. Rettig
Sorry to ask what is probably a neophyte question but I am perplexed.

Macintosh; Apache 2.2 (whatever is the newest), Lasoo 9.2.x, and FMPro 12

If I do a POST, everything gets into the database just fine.
        http://domain.com/poslog.html?poslog=<poslog_here>
        That is, the phrase "<poslog_here>” gets added to the database.

But my customer wants to do a PUT instead; he says because it is 3K big of a blob of text.
Whatever he did, it created the record in the database, but nothing is being added to the database.  I can see the URL he used via the Apache log and it matches.

Here is what is in the file poslog.html

[local(poslog = action_param('poslog'))]
[inline(
        -database=’thedatabase',
        -table=’thecorrecttablename',
        'poslog'=#poslog,
        -add
)]
<POSLog>
Log submitted but not parsed.
</POSLog>
[/inline]

Any suggestions?  Any questions I should ask him to help identity the issue?

Many thanks,
Keith.
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: POST versus PUT

stevepiercy
I don't know the inner workings of action_param, but my guess is
that it only returns GET and POST params.

You could try [web_request] instead.  
web_request->param('paramname') replaces
action_param('paramname') in Lasso 9.  Cast the former to a
string because it could be a NULL:

     local(moose) = web_request->param('hair')->asstring

Nonetheless I don't know whether web_request->param('paramname')
will output a PUT request, so you will have to test.  If not,
there may be something in the section Related Methods that does it.
http://www.lassosoft.com/lassoDocs/languageReference/obj/web_request/param

This might be it:
http://www.lassosoft.com/lassoDocs/languageReference/obj/web_request/raw

--steve


On 3/27/14 at 12:00 AM, [hidden email] (Keith M. Rettig) pronounced:

>Sorry to ask what is probably a neophyte question but I am perplexed.
>
>Macintosh; Apache 2.2 (whatever is the newest), Lasoo 9.2.x, and FMPro 12
>
>If I do a POST, everything gets into the database just fine.
>http://domain.com/poslog.html?poslog=<poslog_here>
>That is, the phrase "<poslog_here>” gets added to the database.
>
>But my customer wants to do a PUT instead; he says because it
>is 3K big of a blob of text.
>Whatever he did, it created the record in the database, but
>nothing is being added to the database.  I can see the URL he
>used via the Apache log and it matches.
>
>Here is what is in the file poslog.html
>
>[local(poslog = action_param('poslog'))]
>[inline(
>-database=’thedatabase',
>-table=’thecorrecttablename',
>'poslog'=#poslog,
>-add
>)]
><POSLog>
>Log submitted but not parsed.
></POSLog>
>[/inline]
>
>Any suggestions?  Any questions I should ask him to help identity the issue?
>
>Many thanks,
>Keith.
>#############################################################
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: POST versus PUT

James Harvard
In reply to this post by Keith M. Rettig
I don't have any real world experience with HTTP 'verbs' / methods other than the bog-standard GET and POST. However I suspect your client's got the wrong end of the stick here...

If you were submitting 30 or 300 MB of data then I might start worrying that you could hit some sort of limit in Apache, Lasso, the Filemaker/Lasso connector or in Filemaker itself. Not with a mere 3KB though! If you're concerned you can check your Apache config file for http://httpd.apache.org/docs/current/mod/core.html#limitrequestbody . But that would limit both POST *and* PUT…

Also, I don't believe what you're doing would be a correct usage of PUT anyway. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6 and, for a discussion of PUT versus POST, http://stackoverflow.com/questions/630453/put-vs-post-in-rest .

Again, I don't have any Lasso 9 experience, but certainly Lasso 8.6 didn't handle things other than GET and POST very comfortably. They're the most commonly used and best understood HTTP methods, so I think the question is: why *not* use POST? Sure, it might be possible to create server-side code to handle PUT or other request methods, but why do it in a more uncommon and more time-consuming way if you don't have to?!

Good luck,
James

On 27 Mar 2014, at 07:00, Keith M. Rettig wrote:

> Sorry to ask what is probably a neophyte question but I am perplexed.
>
> Macintosh; Apache 2.2 (whatever is the newest), Lasoo 9.2.x, and FMPro 12
>
> If I do a POST, everything gets into the database just fine.
> http://domain.com/poslog.html?poslog=<poslog_here>
> That is, the phrase "<poslog_here>” gets added to the database.
>
> But my customer wants to do a PUT instead; he says because it is 3K big of a blob of text.
> Whatever he did, it created the record in the database, but nothing is being added to the database.  I can see the URL he used via the Apache log and it matches.
>
> Here is what is in the file poslog.html
>
> [local(poslog = action_param('poslog'))]
> [inline(
> -database=’thedatabase',
> -table=’thecorrecttablename',
> 'poslog'=#poslog,
> -add
> )]
> <POSLog>
> Log submitted but not parsed.
> </POSLog>
> [/inline]
>
> Any suggestions?  Any questions I should ask him to help identity the issue?
>
> Many thanks,
> Keith.
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: POST versus PUT

Brad Lindsay
In reply to this post by Keith M. Rettig
In RESTful Web Services API design, a POST request is for creating a new
record while a PUT is for updating a record.

That being said, both PUT and POST can use "post params" when making a
request to the browser. Query params (or GET params) are the parameters
in a URL following the question mark. Post parameters are instead sent
in the body of the request.

Most clients limit the size of URLs, so you might not be able to send 3K
worth of data in the url. My guess is that the client wants to be able
to use post parameters and send the data in the body of the request
instead of the URL. This can be done with a POST request just as easily
as a PUT request.

All that being said, it shouldn't matter what type of request they send
you. You have Apache setup to hand off the request to Lasso for
processing, and part of the hand-off is Apache telling Lasso which HTTP
method was used. The only catch would be if you have Apache setup to
deny the HTTP method they use, because then Apache wouldn't hand off the
request to Lasso.

Once Lasso gets the request, the only way the HTTP method is going to
matter is if you have code in place to check the method and do different
things depending on the method.

Now, about using [action_param] - it works like it did in Lasso 8, which
means it plays double-duty for both any parameters passed by the web
request and for any parameters setup inside a surrounding [inline].
Because of this, I would highly recommend using
[web_request->param(`key`)] instead in Lasso 9 as it's more specific to
looking for web parameters passed.

Basic Overview
--------------
web_request->param(`key`)
     Will find the first parameter passed in the URL (query parameter)
or in the body (post parameter) with the specified name - regardless of
HTTP method used.

web_request->queryParam(`key`)
     Will find the first parameter passed in the URL with the specified
name - regardless of HTTP method used.

web_request->postParam(`key`)
     Will find the first parameter passed in the body of the request
with the specified name - regardless of HTTP method used.

(Fuller documentation:
LassoReference: http://www.lassosoft.com/lassoDocs/languageReference/obj/
LassoGuide:
http://lassoguide.com/operations/requests-responses.html#reading-get-and-post-arguments
)


So, take Steve's advice and use [web_request->param] just to make sure
there's no confusion. And you should be able to easily test what happens
by creating your own request.


One final thing to note, if his URL looked like this
"http://domain.com/poslog.html?poslog" without anything being set to
poslog, and then he passed the data in the body, what probably then
happened is that [action_param] picked up the query parameter which was
blank and not the post parameter. If he's going to make a POST or PUT
request, the URL should just be "http://domain.com/poslog.html", and the
parameters in the body of the request should be properly encoded.


HTH,
Brad

On 3/27/14, 3:00 AM, Keith M. Rettig wrote:

> Sorry to ask what is probably a neophyte question but I am perplexed.
>
> Macintosh; Apache 2.2 (whatever is the newest), Lasoo 9.2.x, and FMPro 12
>
> If I do a POST, everything gets into the database just fine.
> http://domain.com/poslog.html?poslog=<poslog_here>
> That is, the phrase "<poslog_here>” gets added to the database.
>
> But my customer wants to do a PUT instead; he says because it is 3K big of a blob of text.
> Whatever he did, it created the record in the database, but nothing is being added to the database.  I can see the URL he used via the Apache log and it matches.
>
> Here is what is in the file poslog.html
>
> [local(poslog = action_param('poslog'))]
> [inline(
> -database=’thedatabase',
> -table=’thecorrecttablename',
> 'poslog'=#poslog,
> -add
> )]
> <POSLog>
> Log submitted but not parsed.
> </POSLog>
> [/inline]
>
> Any suggestions?  Any questions I should ask him to help identity the issue?
>
> Many thanks,
> Keith.
> #############################################################
> This message is sent to you because you are subscribed to
>    the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to:<[hidden email]>
> Send administrative queries to<[hidden email]>
#lasso9 #http
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>