在 AIR 应用程序中执行 POST
我正在尝试将数据发布到为我处理数据的页面。但是,我总是收到以下错误:
ioErrorHandler:[IOErrorEvent type =“ioError” bubbles = false cancelable = false eventPhase = 2 text =“错误#2032:流错误。URL:http://localhost:8080/_user/a/ad/admin/message.create.html" errorID=2032] 块引用
这是我到目前为止的代码。这对于 GET 请求来说效果很好。
// Object that contains data of the message to be sent
var toSend:Object = {
"sakai:type": "internal",
"sakai:sendstate": "pending",
"sakai:messagebox": "outbox",
"sakai:to": "internal:"+sakaimain.gui.dgMessages.selectedItem["to"],
"sakai:subject": sakaimain.gui.dgMessages.selectedItem["subject"],
"sakai:body":"testreply with AIR GUI",
"sakai:previousmessage" : sakaimain.gui.dgMessages.selectedItem["id"]
};
// Send message
// Create loader to load objects
var loader:URLLoader = new URLLoader();
// Add event listeners for error and complete events
loader.addEventListener(Event.COMPLETE, replyMessageCompleteHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, replyMessageErrorHandler);
// Create the request to be done
var request:URLRequest = new URLRequest("http://localhost:8080/_user/a/ad/admin/message.create.html");
request.requestHeaders = new Array(new URLRequestHeader("x-sakai-token", sakaimain.token ));
request.method = URLRequestMethod.POST;
request.data = toSend;
// Do the request
loader.load(request);
有人看到这里的问题吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题已经解决了。我创建了 URLVariables 而不是一个对象来传递,从而解决了问题。
The problem has been solved. I created URLVariables instead of an object to pass through which fixed the problem.
首先检查您的网址。这就是流错误通常发挥作用的地方。确保您可以在 Flex 应用程序之外发布到该 URL。如果不能,您可能会收到更好的错误消息。
您使用什么服务器端语言?您真的打算发布到 .html 文件吗?
如果 URL 准确,请尝试发送仅包含一个键值对的更简单的请求。
另外,我不知道,但是您确定表单变量名称中可以有一个 : 冒号吗?我猜这可能取决于您使用的服务器端语言。
Check your url first. Thats where the stream error generally comes into play. Make sure you can post to that url outside of your flex application. If you can't, you will probably get a better error message.
What server-side language are you using? Are you really intending to be posting to a .html file?
If the url is accurate, try sending a simpler request with only one key-value pair.
Also, I don't know, but are you sure that it is okay to have a : colon in the form variable name? I would guess that might depend on the server side language you are using.