question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Content type "application/x-www-form-urlencoded" with sending KeyValue params

See original GitHub issue

Update:

Here is the Wiki/README/How-to link after the issue was resolved


Issue description

Content type “application/x-www-form-urlencoded” is not supported. Request body is always considered as Json or Multipart.

My rest controlled looks something like below,

@POST
@Consumes({"application/x-www-form-urlencoded"})
public Response handleRequest(MultivaluedMap<String, String> params) {
}

I tried using the below format. But it was failing.

"request": {
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  "body": {
    "Name": "Larry Pg",
    "Company": "Amazon",
    "Title": "CEO"
  }
}

Like to change the method createRequestBuilder of the class BasicHttpClient.

Bit more details:

Not working

  • What is expected ?

    • Content-Type with application/x-www-form-urlencoded with request body should be sent as Key-Value? But sent as text ? Expected: The serve should receive or interpret this as Key-Value pairs?
  • What is actual?

    • It is sent as Text from client(zerocode)? And the server reads as text?

Working

  • What is expected ?

    • Content-Type with application/x-www-form-urlencoded - when sent in the URL like query params, the server receives as Key-Value param
  • What is actual?

    • It is sent like query params from client(zerocode)? and the server reads as Key-Value params?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
arunvelusamydcommented, Oct 24, 2018

I had all my endpoints configured in Postman. I came across this situation, when trying to move all of them to zerocode. postman-zerocode-test

FYI In postman, Body is send as key-value pair. It’s also accepting query params & received as key-value pair. If we do not want to consider body, that’s ok. But it’ll make some confusion.

In my case, key is a simple text and value is a big json ( Ex : address={“unit-no”:"12-07"“block-number”:"33"“apartment”:“Flamingo Valley”,“state/region”:“singapore north”“country”:“singapore”“pincode”:“87654321”} ). It’s too hard to keep them in the url.

Anyway, let’s decide by others thought and specifications. Thanks.

1reaction
authorjappscommented, Oct 25, 2018

Folks, all concerns have been taken care now in the PR. Please have a look, review n approve- Overall the below things has been take care n will be available once merged -

  • Request body can be passed as key-value pair for this header type - let’s keep this feature as this is a natural choice for users (we can add into readme 👍 @arunvelusamyd )
  • queryParams also now has been enhanced to take care of special chars - the similar logic from the PR has been implemented
  • BasicHttpClient some methods are public intentionally as they are already in use in the corporates, where they put their custom logic/headers/request-builder/corporate-prosy etc via @UseHttpClient. Just a note of caution not to make it private
  • Better test coverage now for both body and queryParams handling
  • HelloWorld project has been verified with 1.2.9-SNAPSHOT build 👍

I will keep it open for a day and merge it. If it is super urgent, let me know !

@officiallysameer @dinesh76in @macrocks @cooljavadev FYA please.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling URL Encoded Form Data in Spring REST - Baeldung
An HTTP request that sends application/x-www-form-urlencoded data must specify this in the Content-Type header. Internally, Spring uses the ...
Read more >
How to send x-www-form-urlencoded keyValue pair parameters
Hi, I have a post request where i need to send x-www-form-urlencoded keyValue pair parameters and content-type should be x-www-form-urlencoded.
Read more >
How do I POST a x-www-form-urlencoded request using Fetch?
In both cases you have 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' so you are claiming to be sending Form Encoded data in both cases. Use ...
Read more >
POST - HTTP - MDN Web Docs
A POST request is typically sent via an HTML form and results in a change on the server. In this case, the content...
Read more >
Retrofit — Send Data Form-Urlencoded - Future Studio
Place your desired key inside the @Field("key") annotation to define the parameter name. Further, add the type of your value as the method ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found