Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

status 400 Bad Request

I am trying to run a DELETE service on one of my collections. It works if I test it manually, but when I make a call to it I get a status 400 Bad Request.

I think that I am passing the right parameters, but there must be someething that I am missing.

My app is called "sherakbar vip", it is shared with support. Can you point out what is amiss.

to recreate the issue:

  1. login as admin password is ravine

  2. At the bottom of the list click Administration

  3. Select Gallery

  4. Select Delete Gallery Item

  5. Click the first item in the list

  6. check console log

    The text field of the list item contains the id of the record

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

status 400 Bad Request

Hello!

Thank you! We'll test and let you know.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

status 400 Bad Request

When you say "test it manually" do you mean test in editor?

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

status 400 Bad Request

yes, using the test option in the service, ie not from my app

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

status 400 Bad Request

Hi Terry,

Tried your app.

And here is a culprit of your problem:
http://prntscr.com/6acb5s/direct

So you have something wrong in your settings or value that you pass to "_id" request parameter.

If you can not manage to fix this problem - please show us service settings and how do you map value to _id parameter.

Regards

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

status 400 Bad Request

Ok, I have located where the 'Item 1' part of my url was coming from, it was a rogue mapping which shouldn't have been there. However, it still does not seem to be creating the url correctly.

The service does work, I have run it from the test tab in the service and it does exactly what I intended.

The url my app seems to create is incorrect. This is a section from the log:

DELETE https://api.appery.io/rest/1/db/colle... 400 (Bad Request)

Obviously the '?_id=' should not be part of the url, but I can't see why it's there.

The service settings are:
Image

The service is called with the following javascript:
code
id = stringClean($(this).text());
console.log("id = ",id);
deleteService.execute({data:{"_id":id}});
/code
The js is the click event of the list component

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

status 400 Bad Request

Hi Terry,

You have following actual URL:

pre

https://api.appery.io/rest/1/db/collections/Gallery/?_id=54f16abde4b0266e547f8ec3

/pre

But it should something like:

pre

https://api.appery.io/rest/1/db/collections/Gallery/54f16abde4b0266e547f8ec3

/pre

Please read more about delete service here: http://devcenter.appery.io/documentat...

Regards.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

status 400 Bad Request

I know what the url should be. I thought that I needed to pass the id to the service and that codedeleteService.execute({data:{"_id":id}});/code would do the trick. The value of id is 54f16abde4b0266e547f8ec3 which is the id of the record in the gallery collection.

What I can't figure out is where '?id=' is coming from

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

status 400 Bad Request

Hi Terry -

1) Remove parameter id from the "Query String" tab of request tab of your service.
2) Add new parameter "id_forDeletion" in the settings service.
3) Add instead {id} {id_forDeletion} at the end of your service's URL.
4) On Settings tab of your service select settings name which has this parameter.
5) Before send request you should always define id_forDeletion value
-- e.g.: Settings.id_forDeletion = "123123123123123";

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

status 400 Bad Request

Is this what you mean?:

Image

Image

Image

javascript to call service:
preid = stringClean($(this).text());
console.log("id = ",id);
Settings._id_forDeletion = id;
deleteService.execute({});/pre

It seems a bit strange adding a blank item to a settings service?

Return to “Issues”