node.js - Angularjs 发送post请求时报415错误.
PHP中文网
PHP中文网 2017-04-17 11:54:51
0
1
570

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

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
阿神

This problem is solved:
The 415 error should be a content-type problem, but angularjs supports post contentType="application/json" by default. The reason for this problem is that Apigee Edge and APIGEE act as a bridge between web service providers and APP developers. Provides a relatively stable interface for both parties to connect, making the developer's development process more unified and consistent, and improving development efficiency; making the service provider's APP easier to manage; 415 appears when angular sends a post request to the background because it is in http There is no grant type configured for web and server connections. 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. Reference: http://apigee.com/docs/api-services/content/oauth-20-client-credential...
400: The error is that the RequestBody is not configured and the parameters are incorrectly configured.
All this problem should be configured with parameters in the angular http service as follows:
data: {'grant_type': 'client_credentials'},
data: { 'Id': '11' }
The problem is solved! Hope it is useful to everyone...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template