0

I currently have an application using Parse as a BaaS. I created a web crawler in Python because it's fairly simple and I'm hosting the code for that crawler on Heroku. My problem is I'm trying to call that Python script from an httpRequest in Parse Cloud Code using a POST request because a GET request is limited on the size of the data you can get back. Also, using a GET request works for fetching the page and running the code, I just don't get the data back. When I use a POST request I run into a problem with the Heroku server that says


    

Forbidden (403)

CSRF verification failed. Request aborted.

You are seeing this message because this HTTPS site requires a 'Referer header'

to be sent by your Web browser, but none was sent.

Here is my Cloud Code httpRequest on Parse (I'm not very familiar with requests so something is probably flawed on my side)

Parse.Cloud.httpRequest({
    method: 'POST',
    url: 'https://vast-basin-5892.herokuapp.com/',
    body: {
        beer: request.params.beer
    },
    params: {
        beer : request.params.beer
    },
    success: function(httpResponse){
        response.success(httpResponse.text);
    }, error: function(httpResponse){
        response.error(httpResponse);
    }
});

I have been struggling with this for several days and would appreciate any help.

thailey01
  • 165
  • 1
  • 14
  • It looks like this - http://stackoverflow.com/questions/9692625/csrf-verification-failed-request-aborted-on-django – Sandr Jan 15 '16 at 12:36
  • I don't have a form in a template though. I just have a python script I'm trying to POST to. – thailey01 Jan 15 '16 at 18:18

1 Answers1

1

You wrote : "GET request is limited on the size of the data you can get back" - it is't true. GET request has limit on size of data you can send.

Have you tried to send GET request?

Sandr
  • 189
  • 9
  • GET request does work on running the crawler, everything is fine in that respect, but when I try and get all the data my crawler returns via GET for some reason my Parse app doesn't get all the data back. Only when I return shorter text (which is actually what I'm returning in the crawler) will I actually receive it on Parse. – thailey01 Jan 15 '16 at 21:15
  • I actually just read about http methods at http://www.w3schools.com/tags/ref_httpmethods.asp and I think I misread it the first time I went through. Initially, I though it said you were limited on the data you got back because I though that data was returned in the url. but upon second inspection I think my initial thought was wrong and you can only send so much data because it goes in the url, but the data isn't returned in the url. So that must mean if the crawler works with a curl request then something must be wrong on the client side. – thailey01 Jan 15 '16 at 21:32
  • Ok, so i've got the httpRequest call to work with GET but it seems like I cannot get big results back. Basically what is happening is I search for a beer in a site and return the description I get back. The request works when the description is small, but when it's larger it doesn't work. – thailey01 Jan 16 '16 at 02:11
  • What type of data you are getting? Show your get request. – Sandr Jan 16 '16 at 07:17
  • I'm just receiving a string back. – thailey01 Jan 16 '16 at 07:21
  • I've manage to get the string back with the GET request, thanks for your help. – thailey01 Jan 16 '16 at 20:41