Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not send field when in url #204

Open
cubistico opened this issue Feb 15, 2022 · 4 comments
Open

Do not send field when in url #204

cubistico opened this issue Feb 15, 2022 · 4 comments

Comments

@cubistico
Copy link

I'm trying to use RESTool with an API that, when creating a new user, requires a PUT request with the new user name in the URL.

Now if I define

        "post": {
          "actualMethod": "put",
          "url": "/users/:username",
          "fields": [
            {
              "name": "username",
              "type": "text",
              "label": "User name"
            },
            {
              "name": "password",
              "type": "text",
              "label": "Password"
            }
          ]
        }

the server returns an error because the field is not expected in the body. However, if I don't define it in "fields", the UI will not generate a corresponding input field.

A possible solution would be exclude the field from the body if it is already part of the url.

Perhaps there is a solution with custom fields, but if so, I don't know how to use them for an "Add Item" functionality.

@cubistico
Copy link
Author

I also noticed that ":username" won't be replaced at all in my url, so it looks like POST works differently which appears unexpected and unnecessarily inconsistent to me, although I see there was a good reason for this – the REST API I'm trying to work with does not adhere to the standards well.

I checked the customActions functionality, but with that, I seem unable to create something like the Add Item button, because I can only add actions to the items in the item list.

@dsternlicht
Copy link
Owner

@cubistico you may add the useInUrl property on this field and set it to true. I think this will solve it.

@cubistico
Copy link
Author

cubistico commented Feb 16, 2022

@cubistico you may add the useInUrl property on this field and set it to true. I think this will solve it.

I'm afraid it doesn't. This is the url it generates with useInUrl:
http://my.test.server/users/:username?username=aaa

Not what I would expect. Plus, it still also includes username in the body, which is actually what is stated in the docs:

If true, a field can be used as a parameter in a PUT url. Otherwise only fields retrieved in the original GET can be used as parameters. Its data will still be added to the PUT request body.

I wonder if that makes sense in any scenario? I would think that the data would be expected in either the url or the body?

@dsternlicht
Copy link
Owner

Hmmm I guess it makes sense, but currently not supported. You're more than welcome to add it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants