角2 HTTP POST错误

编程入门 行业动态 更新时间:2024-10-21 16:32:54
本文介绍了角2 HTTP POST错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个离子2应用程序,将获得来自Facebook的一些事件。我试图发送POST请求的图形API包含rel=\"nofollow\">一批href=\"developers.facebook/docs/graph-api/making-multiple-requests\"一个的,但我的订阅总是返回这个错误:

I have an Ionic 2 app that will get some events from Facebook. I'm trying to send a post request to the Graph Api with a batch containing multiple requests but my subscription always return this error:

{_体:,状态:404,状态文本:OK,头:{客户通过  [shouldInterceptRequest]},型:2,URL: graph.facebook/ }

{"_body":"","status":404,"statusText":"Ok","headers":{"Client-Via", ["shouldInterceptRequest"]},"type":2,"url":"graph.facebook/"}

我的组件里面订阅:

this.eventListService.get() .subscribe( response => this.response = response, error => this.error = error )

EventListService:

EventListService:

import {Injectable} from '../../node_modules/angular2/core'; import {Http, Headers, URLSearchParams} from '../../node_modules/angular2/http'; import {Observable} from '../../node_modules/rxjs/Rx'; import {AuthenticationService} from '../user/authentication.service'; @Injectable() export class EventListService { private fields: string = 'id, cover, name, start_time, place, attending_count, interested_count, rsvp_status'; constructor( private http: Http, private authenticationService: AuthenticationService ) {} get() { return Observable .fromPromise(this.authenticationService.getAccessToken()) .flatMap(accessToken => this.synchronize(accessToken)); } synchronize(accessToken) { const today = new Date(); today.setHours(0, 0, 0, 0); const todayTimestamp = today.getTime(); const batch = [{...}]; const headers = new Headers(); headers.append('Content-Type', 'application/x-www-form-urlencoded'); const body = new URLSearchParams(); body.append('access_token', accessToken); body.append('batch', JSON.stringify(batch)); return this.http .post('graph.facebook', body.toString(), { headers }) .map(response => response.json()); } }

任何想法,为什么提出要求时,我得到这个错误?

Any idea why I'm getting this error when making the request?

推荐答案

一个404错误=未找到( HTTPS ://en.wikipedia/wiki/HTTP_404 )

A 404 Error = Not Found (en.wikipedia/wiki/HTTP_404)

所以,可能你的网址错误的任何资源,您试图访问,或者一些其他问题的连接。

So probably you have the url wrong for whatever resource you are trying to access, or else some other problem with your connection.

事实上 - 如果我尝试手动从我的浏览器我转到 graph.facebook 得到一个404错误。

Indeed - if I manually try to navigate to graph.facebook from my browser I get a 404 error.

由于这是使用https协议,它可以是一个身份验证问题了。

Since this is using an https protocol, it could be an authentication issue too.

更多推荐

角2 HTTP POST错误

本文发布于:2023-10-11 23:14:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483109.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   HTTP   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!