我正在尝试使用蜂群api执行测试,如下所示:
$scope.createAsset = function () {
$http({
method: 'POST',
url: 'http://polls.apiblueprint.org/createStory',
headers: {'Access-Control-Allow-Origin': '*'}
});
}蜂房:
FORMAT: 1A
HOST: http://polls.apiblueprint.org/
# BulBulTest
BulBulTest is a simple API for testing.
## Create story [/createStory]
### Create story [POST]
+ Response 200 (application/json)
{
"Status": "Story created sucessfully",
"published_at": "2015-08-05T08:40:51.620Z",
"publisher": "Johm Smith"
}即使在设置了allow-origin之后,我也得到了错误。
发布于 2016-05-27 19:06:55
您对CORS有一个误解:Access-Control-Allow-Origin头来自服务器,而不是客户端。是服务器决定是否允许跨域调用。
如果服务器不支持跨域调用,那么您无法在客户端代码中启用跨域调用。
发布于 2016-05-27 19:09:53
我不认为你必须设置"Access-Control-Allow-Origin",但是你可能遗漏了一些额外的参数,因为这是一个POST调用。如果你有应用程序接口方法的详细信息,那么检查"@RequestParams".Hope中需要哪些参数,这可能会有所帮助。
https://stackoverflow.com/questions/37481764
复制相似问题