我正在使用POSTMAN
应用程序对我的Scala Akka应用程序执行REST call (POST, GET)
。如果我从angularJS做同样的调用它可以工作,但是当我从POSTMAN中激活它时它会出现以下错误:
There was a problem with the requests Content-Type:
Expected 'application/json'
我的POST
来电是:
http://localhost:8090/user/signUp
包含我在Postman的Body
标签中添加的3个请求参数。
我的标题需要一个值,App_Id
,我在Headers
中添加了我添加的值
Content-Type : application/json
在标题中但仍然邮递员给出了上述错误。
我的申请代码是:
val route =
post {
path("user" / "signUp"){
headerValueByName("App_Id") { app_id => {
handleWith {
//application specific implementation
}
}
}
}
答案 0 :(得分:5)
谢谢@tokkov& @cmbaxter为你提供帮助..最终它有效。
我在标题中添加了Content-Type : application/json and App_Key : xxx
。
并在Raw
中请求类型为Json(application/json)
的请求参数。像这样:
{
"email" : "xxx",
"name" : "TEST NAME",
"password" : "xxx"
}
所以我的问题是添加请求参数,我将在raw
添加,但我正在尝试form-data and x-www-form-urlencoded