5

I am using POSTMAN app for doing REST call (POST, GET) to my Scala Akka Application. if i do the same call from angularJS it works but when i fire it from POSTMAN it gives following error :

There was a problem with the requests Content-Type:
Expected 'application/json'

My POST Call is :

http://localhost:8090/user/signUp

which contains 3 request parameters which i added in Body tab of Postman. my Header requires one value i.e App_Id which i added in Headers also i added

Content-Type : application/json

in Header. but still postman gives above error.

My Application Code is :

val route =
    post {
      path("user" / "signUp"){
        headerValueByName("App_Id") { app_id => {
            handleWith {

                   //application specific implementation

            }
        }
        }
      }
Nilesh
  • 2,054
  • 3
  • 23
  • 43
  • Did you add the parameters are form-data or raw? Based on the error I would guess that the body of the POST is not a valid JSON object. Can you show the actual data management part of the POST in angular since it is a success and will be extremely informative? – tokkov Jul 14 '16 at 12:14
  • As @tokkov mentioned, you are telling the server one thing but doing another. You are saying that the body is json when in fact, it appears to be form urlencoded content data. Try changing the content type to: `application/x-www-form-urlencoded` and see if that works. – cmbaxter Jul 14 '16 at 12:39
  • Hi @tokkov, i tried adding params in form-data still it gives error like _"The request content was malformed: Unexpected character '-' at input index 1 (line 1, position 2), expected DIGIT: ------WebKitFormBoundaryd0iYY8aDZPZxCE28? ^"_ – Nilesh Jul 15 '16 at 06:01
  • @cmbaxter thanks for suggesting but when i changed content-type `application/x-www-form-urlencoded` but it gives same error `There was a problem with the requests Content-Type: Expected 'application/json'` – Nilesh Jul 15 '16 at 06:10

1 Answers1

5

Thanks @tokkov & @cmbaxter for your help..finally it is worked.

I added Content-Type : application/json and App_Key : xxx in Headers. and request parameters in Raw with type Json(application/json). Like this:

{
    "email" : "xxx",
    "name" : "TEST NAME",
    "password" : "xxx"

 }

So My problem is with adding Request Parameters which i would to add in raw but i am trying in form-data and x-www-form-urlencoded

Nilesh
  • 2,054
  • 3
  • 23
  • 43