curlhttpclientopentext

POST request (form data) with JetBrains HTTP Client doesn't work


This request to a OpenText Content Server works with the curl, but doesn't work with the JetBrains HTTP Client.

curl --location --request POST 'http://myserver/api/v1/auth' \
--form 'username="myuser"' \
--form 'password="mypassword"'

This command above works as expected.

POST myserver.mydomain
Accept: */*
Content-Type: multipart/form-data; boundary=WebAppBoundary

--WebAppBoundary
Content-Disposition: form-data; name="username"

myuser
--WebAppBoundary
Content-Disposition: form-data; name="password"

mypassword
--WebAppBoundary--

This doesn't work, returns a message about a wrong password.

I would appreciate any suggestions regarding the issue.


Solution

  • I should've used "Content-Type: text/plain". This works just fine.

    POST http://myserver.local/api/v1/auth
    Content-Type: multipart/form-data; boundary=---------------------------974767299852498929531610575
    
    -----------------------------974767299852498929531610575
    content-Disposition: form-data; name="username"
    Content-Type: text/plain
    
    myusername
    -----------------------------974767299852498929531610575
    content-Disposition: form-data; name="password"
    Content-Type: text/plain
    
    mypassword
    -----------------------------974767299852498929531610575--
    

    Documentation: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type