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

Support multiline request body for x-www-form-urlencoded #169

Closed
fabianschlier opened this issue Feb 28, 2018 · 9 comments
Closed

Support multiline request body for x-www-form-urlencoded #169

fabianschlier opened this issue Feb 28, 2018 · 9 comments

Comments

@fabianschlier
Copy link

  • VSCode Version: 1.11.2
  • OS Version: Win7
  • REST Client Version: 0.14.2

Hi,

thanks for this cool extension, it eases our quick testing so much! But one thing is a bit sticky.

One of our applications makes heavy use of post reqeusts with application/x-www-form-urlencoded bodies. This works pretty well, but all parameters need to be given in one line

arg0=val0&arg1=val1&arg2=val2

If there are many/long parameters, this makes it pretty ugly to keep track of the parameters. It would be nice to support multi lining of the parameters. I sneaked around in the code a bit and it seems that there is already a EOL normalization here: https://github.com/Huachao/vscode-restclient/blob/master/src/controllers/codeSnippetController.ts#L205
But I did not manage to get this triggered. My Request looks like this:

POST https://host:8443/my/path/to/endpoint HTTP/1.1
Content-Type: application/x-www-form-urlencoded

arg0=val0&arg1=val1&arg2=val2

Am I missing something, point me out. If not, it would be nice to support nice multi lines:

POST https://host:8443/my/path/to/endpoint HTTP/1.1
Content-Type: application/x-www-form-urlencoded

arg0=val0
&arg1=val1
&arg2=val2

Thanks
Fabian

@Huachao
Copy link
Owner

Huachao commented Apr 20, 2018

@fabianschlier I have implemented this feature, and will publish this in next release.

@Huachao
Copy link
Owner

Huachao commented Apr 23, 2018

@fabianschlier @ashee @juunas11 @ljyf5593 @noark9 @jenan-stripe you can try the latest version 0.18.3 to verify this feature. The syntax follows what @fabianschlier described:

POST https://host:8443/my/path/to/endpoint HTTP/1.1
Content-Type: application/x-www-form-urlencoded

arg0=val0
&arg1=val1
&arg2=val2

@fabianschlier
Copy link
Author

@Huachao this works good. Thanks for adding this feature. Especially when working with big requests the files are readable much better now.

@PiotrPerak
Copy link

Is there a way to assign contents of a file to one of arguments? I can't manage to do it.

arg0=val0
&arg1=path_to_file.xml

@fadl8
Copy link

fadl8 commented Oct 24, 2020

I write like the in my request

Content-Type: application/x-www-form-urlencoded

I get that error

HTTP/1.1 400 Bad Request

{
"error": "unsupported_grant_type"
}

@Huachao
Copy link
Owner

Huachao commented Oct 26, 2020

@fadl8 could you please show me your actual request?

@bree7e
Copy link

bree7e commented Jan 19, 2022

I get that error

HTTP/1.1 400 Bad Request

{ "error": "unsupported_grant_type" }

It works like this

POST http://localhost:8080/auth/realms/master/protocol/openid-connect/token
Content-Type: application/x-www-form-urlencoded

client_id=portal
&username=admin
&password=password
&grant_type=password

@Huachao
Copy link
Owner

Huachao commented Jan 19, 2022

POST http://localhost:8080/auth/realms/master/protocol/openid-connect/token
Content-Type: application/x-www-form-urlencoded

client_id=portal
&username=admin
&password=password
&grant_type=password

Does it work for you if you merge multiple lines into single one?

@bree7e
Copy link

bree7e commented Jan 19, 2022

Does it work for you if you merge multiple lines into single one?

Yes, it works when merge into one line.

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

No branches or pull requests

5 participants