Jersey client Post Request with x-www-form-urlencoded Fails
<p>Hi I am using Glassfish jersey-client to get oauth-Token from REST URL.
I am able to get the token via postman client &amp; CURL,please find the below image for reference,</p>

<pre><code>$ curl 'https://sample.com/oauth2/token' -X POST -d'g
rant_type=samples&amp;id=2ZwqWBdksfjkads6Q8yNW3s58LNeOMucJeb&amp;s                                                                                                                
ecret=dkfflJTZOqA1GCEH&amp;scope=GROUP'
</code></pre>

<p>But unable to achieve it via code,</p>

<pre><code>&lt;dependency&gt;
        &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
        &lt;version&gt;2.22.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-media-json-jackson&lt;/artifactId&gt;
        &lt;version&gt;2.22.2&lt;/version&gt;
    &lt;/dependency&gt;
</code></pre>

<p>I am using following code to get the token</p>

<pre><code>Form form = new Form();
        form.param("grant_type", "samples");
        form.param("id", "2ZwqWBdksfjkads6Q8yNW3s58LNeOMucJeb");
        form.param("secret", "HGoslJTZOqA1GCEH");
        form.param("scope", "dkfflJTZOqA1GCEH");
JerseyClientBuilder jerseyClientBuilder = new JerseyClientBuilder()
            .register(new LoggingFilter());
    JerseyWebTarget jerseyWebTarget =      jerseyClientBuilder.build().target(hostname);
        response = jerseyWebTarget.request().accept(MediaType.APPLICATION_FORM_URLENCODED).post(Entity.form(form));
</code></pre>

<p>Keep on getting StatusCode=406(Not acceptable) as a response.
Shall i passing the URL parameters properly?</p>

<p>I would highly appreciate if someone give me a hint to resolve this issue.</p>