首页 > Angularjs 发送post请求时报415错误.

Angularjs 发送post请求时报415错误.

Nodejs转发后台post接口,前台angularjs负责发送,发现不管怎样设置headers,content-type和$http服务,浏览器都报415 error,说是Unsupported Media Type,请问大牛如何解答?


这个问题解决了:
415错误应该是content-type的问题,但是angularjs默认支持post contentType="application/json",出现这个问题的原因是因为,Apigee Edge,APIGEE充当了web服务提供者与APP开发者之间的桥梁,对双方都提供相对稳定的接口进行连接,使得开发者的开发过程更加统一、一致,提高开发效率;使服务提供者的APP更加易于管理;angular向后台发送post请求的时候出现415是因为在http里面没有配置web和服务器连接的授权类型(grant type)an app sends it's own credentials (the Client ID and Client Secret) to a GenerateAccessToken endpoint on Apigee Edge. If the credentials are valid, Edge returns an access token to the client app.参考:http://apigee.com/docs/api-services/content/oauth-20-client-credential...
400:错误是没有配置RequestBody,参数配置有误。
所有这个问题应该在angular http服务里面配参数如下:
data: {'grant_type': 'client_credentials'},
data: { 'Id': '11' }
问题就解决了!希望对大家有用...

【热门文章】
【热门文章】