0

So I am trying to get the cloud code to do an aftersave event that pings another location to do some data saving.

It has some data that needs to be sent as well.

Parse.Cloud.afterSave("ArtPiece", function(request) {
var artistURL = 'http://www.gallery-admin-dev.iartview.com/Gilmans/imageSave.php';

var pieceName = "Robert Rauschenberg Quote";
var url = 'http://www.gilmancontemporary.com/wp-content/uploads/2015/06/Delicate_Garden.The_Bear.48x42.jpeg';

Parse.Cloud.httpRequest({
    url: artistURL,
    dataType : "text",
    crossDomain: true,
    type:"GET",
    data : {
      pieceName : pieceName,
      url : url
    },

    success: function(httpResponse) {
        response(httpResponse.text);
    },
    error: function(httpResponse) {
        response('Request failed with response code ' + httpResponse.status)
    }
});

});

The code does not give an error, or any warnings. Me saving/creating entries works fine.

Cors is already handled, as I can successfully make this call with an ajax script.

Any clue why this is not sending? Can I not have data in a parse httpRequest? Can it not be crossdomain?

Alternatively Is there a way to test this code outside of the Parse Cloud???

0

1 Answer 1

2

The way you call httpRequest function is not correct in cloud. You also do not need to worry about CORS as you are not working in a browser environment. Try this instead:

Parse.Cloud.httpRequest({
    url: artistURL,
    params: {
      pieceName : pieceName,
      url : url
    },
    success: function(httpResponse) {
        response(httpResponse.text);
    },
    error: function(httpResponse) {
        response('Request failed with response code ' + httpResponse.status)
    }
});

To test this outside cloud environment you can use the curl command. It will be something like:

curl -G -v "http://www.gallery-admin-dev.iartview.com/Gilmans/imageSave.php" --data-urlencode "pieceName=Robert Rauschenberg Quote,url=http://www.gilmancontemporary.com/wp-content/uploads/2015/06/Delicate_Garden.The_Bear.48x42.jpeg"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.