Page 1 of 2

status 400 Bad Request

Posted: Tue Feb 24, 2015 6:45 pm
by Terry Gilliver

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


status 400 Bad Request

Posted: Wed Feb 25, 2015 7:51 am
by Maryna Brodina

Hello!

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


status 400 Bad Request

Posted: Wed Feb 25, 2015 1:14 pm
by Maryna Brodina

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


status 400 Bad Request

Posted: Wed Feb 25, 2015 2:39 pm
by Terry Gilliver

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


status 400 Bad Request

Posted: Fri Feb 27, 2015 3:31 am
by Yurii Orishchuk

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


status 400 Bad Request

Posted: Sat Feb 28, 2015 7:32 am
by Terry Gilliver

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


status 400 Bad Request

Posted: Tue Mar 03, 2015 5:30 am
by Yurii Orishchuk

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.


status 400 Bad Request

Posted: Tue Mar 03, 2015 1:55 pm
by Terry Gilliver

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


status 400 Bad Request

Posted: Wed Mar 04, 2015 11:30 am
by Illya Stepanov

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";


status 400 Bad Request

Posted: Wed Mar 04, 2015 12:13 pm
by Terry Gilliver

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?