![](/img/trans.png)
[英]http post not working on my code, but working on postman(rest api client)
[英]Postman gives error for REST based POST methods
我正在使用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
其中包含3个请求参数,我在Postman的Body
选项卡中添加了这些参数。 我的标题需要一个值,即我在添加的Headers
添加的App_Id
Content-Type : application/json
在标题中。 但邮递员仍然给出了上述错误。
我的申请代码是:
val route =
post {
path("user" / "signUp"){
headerValueByName("App_Id") { app_id => {
handleWith {
//application specific implementation
}
}
}
}
感谢@tokkov和@cmbaxter的帮助..最终它的确有效。
我在Headers中添加了Content-Type : application/json and App_Key : xxx
。 并使用类型Json(application/json)
请求Raw
参数。 像这样:
{
"email" : "xxx",
"name" : "TEST NAME",
"password" : "xxx"
}
所以我的问题是添加请求参数,我将添加raw
但我正在尝试form-data and x-www-form-urlencoded
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.