2

I'm trying to make a POST request from Parse to Firebase, using Parse Cloud Code and Firebase's REST API.

Parse.Cloud.define("createChatRoom", function(request, response) {

  Parse.Cloud.httpRequest({
    url: 'https://myapp.firebaseIO.com/' + '.json',
    method: 'PUT',
    body: {"hi": "hello"}
  }).then(function(httpResponse) {
      response.success("Successfully posted hello!");
  },function(httpResponse) {
      response.error("failed to post hello" + httpResponse.text)
  })
})

However, this code makes Firebase respond with the following error:

"Invalid data; couldn't parse JSON object, array, or value. Perhaps you're using invalid characters in your key names."

I have tried a multitude of combinations for body, including variations of apostrophes, integers, and removing brackets altogether.

Any ideas?

2 Answers 2

1

Answering my question:

JSON for Firebase must be wrapped in single quotes ':

body: '{"hi": "hello"}'

Sign up to request clarification or add additional context in comments.

Comments

0

I think it's better to use like this body: JSON.stringify({"hi": "hello"})

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.