RejectedSoftware Forums

Sign up

@bodyParam with parameters called id

Using the REST Interface I want to receive a parameter called 'id' in the body of a POST request, but 'id' has special handling to be embedded into the URL. So I thought, I could use @bodyParam, which does not work. Is this intended and is there a work around to the problem?

Thanks, Tobias

interface WorkQueueAPI
{
   void addJob(Job job);
	
   @bodyParam("id")
   void deleteJob(int id);

   @property Job[] jobs();
}

Re: @bodyParam with parameters called id

On 9/19/19 2:10 PM, Tobias Pankrath wrote:

Using the REST Interface I want to receive a parameter called 'id' in the body of a POST request, but 'id' has special handling to be embedded into the URL. So I thought, I could use @bodyParam, which does not work. Is this intended and is there a work around to the problem?

Thanks, Tobias

interface WorkQueueAPI
{
    void addJob(Job job);
	
    @bodyParam("id")
    void deleteJob(int id);

    @property Job[] jobs();
}

Yeah, this is an annoying aspect of vibe.d REST. I can think of a couple
ways -- 1. rename the parameter to something like ID. 2. Use a @before
clause to exctract the id from the form data into an _id parameter.

-Steve

Re: @bodyParam with parameters called id

interface WorkQueueAPI
{
    void addJob(Job job);
	
    @bodyParam("id")
    void deleteJob(int id);

    @property Job[] jobs();
}

Yeah, this is an annoying aspect of vibe.d REST. I can think of a couple
ways -- 1. rename the parameter to something like ID. 2. Use a @before
clause to exctract the id from the form data into an _id parameter.

-Steve


@bodyParam("jobId", "id")
void deleteJob(int jobId)

works for me.

Re: @bodyParam with parameters called id

On 9/20/19 12:07 PM, Tobias Pankrath wrote:


@bodyParam("jobId", "id")
void deleteJob(int jobId)

works for me.

Nice! good to know that works.

-Steve