Post data on Kinvey DataStore with Business Logic

312 views Asked by At

I just started to work with Kinvey and I'm having some issues to POST data via REST api. If I go in the datastore I'm able to save it, but it doesn't work when sending via POST.

To post data, I'm using the URL "/appdata/APP_KEY/DATASTORE/" and sending Authorization, X-Kinvey-API-Version and Content-Typein the Headers.
And I get back "An unknown internal error occured in the processing of the Business Logic code."

When I add my business logic with App Engine (for a while, it just returns status=200 to Kinvey), I have the same error:

{
  "error": "BLInternalError",
  "description": "The Business Logic script did not complete. See debug message for details.",
  "debug": "An unknown internal error occured in the processing of the Business Logic code."
}

Does anyone have any idea where am I doing wrong?

For the last, even when I call Kinvey via GET the method that Kinvey calls App Engine is POST, is there a way to change it?

Despite the errors, I always have the log of access in Google App Engine.

Thank you!

1

There are 1 answers

0
Mario Jorge Valle On BEST ANSWER

I sent an email to Kinvey support and they helped me a lot. Some of my mistakes:

  1. The JSON that I was returning back was wrong [*];
  2. I didn't add in the header of my response the Content-Type and status.

Now it works perfectly!

[*] The JSON that I send back in the body of the response is:

{
    "request": {
        "method": "<redacted>",
        "username": "<redacted>",
        "entityId": "<redacted>",
        "collectionName": "<redacted>",
        "headers": {
            "connection": "<redacted>",
            "host": "<redacted>",
            "x-forwarded-for": "<redacted>",
            "x-forwarded-port": "<redacted>",
            "x-kinvey-api-version": "<redacted>",
            "x-real-ip": "<redacted>",
            "authorization": "<redacted>",
            "x-forwarded-proto": "<redacted>"
        },
        "body": "<redacted>",
        "params": "<redacted>"
    },
    "response": {
        "complete": True,
        "headers": {
            "x-powered-by": "<redacted>",
            "x-kinvey-api-version": "<redacted>",
            "x-kinvey-request-id": "<redacted>"
        },
        "body": {},
        "error": None,
        "statusCode": 200
    }
}

Thanks again to Brian in the Kinvey support!

[]'s