Can you check this routing is correct?
api_createuser:
url: /rest/userregistration.:sf_format
class: sfDoctrineRoute
param: { module: rest, action: user, sf_format: json }
options: { model: Stbuser, type: object }
requirements:
sf_method: post
And in the action class I create a function for this. It is not
working
public function executeUser(sfWebRequest $request)
{
if ($request->isMethod('post')) {
print_r($request);
}
}
used this url for accessing this api.
http://localhost/restwebservice/rest/userregistration
But for GET I create the routing entry as given below and it working
fine with the url http://localhost/restwebservice/rest/women.
api_women:
url: /rest/women.:sf_format
class: sfDoctrineRoute
param: { module: rest, action: women, sf_format: json }
options: { model: Women, type: list, method: getWomens }
requirements:
sf_format: (?:xml|json)
On Aug 31, 5:55 pm, Gareth McCumskey <[email protected]> wrote:
> There is no need to worry about routing as you can handle REST request all
> within the index action (or whatever other default action you may have
> already setup in your routing for modules) and do checks on whether an
> incoming is a post request. For example:
>
> public function executeIndex (sfWebRequest $request)
> {
> if ($request->isMethod('post'))
> {
> $post_parameters = $request->getPostParameters();
> $this->processPostRequest($post_parameters);
> }
> else if ($request->isMethod('get'))
> {
> $get_parameters = $request->getGetParameters();
> $this->processGetRequest($get_parameters);
> }
>
> }
>
> public function processPostRequest($parameters)
> {
>
> //Whatever code here you need to do whatever you want with the post
> parameters
>
> }
>
> public function processGetRequest($parameters)
> {
>
> //Whatever code here you need to do whatever you want with the get
> parameters
>
>
>
>
>
> }
> On Tue, Aug 31, 2010 at 2:00 PM, Shihab KB <[email protected]> wrote:
> > Dear friends,
>
> > I would like to do one REST API for creating a users by POST method. I
> > am new to REST, php & symfony. I just now created a rest api to get
> > uses from the database.
>
> > Can somebody help me by providing a samples for creating a rest api
> > with POST method... I request you to give me the entry in the routing
> > file, function to be created in the action class and templates. And
> > some test code also. Can you please help me.
>
> > regards
> > Shihab
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<symfony-users%2bunsubscr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en
>
> --
> Gareth McCumskeyhttp://garethmccumskey.blogspot.com
> twitter: @garethmcc- Hide quoted text -
>
> - Show quoted text -
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en