Iglu Server guide "The request body was invalid"

Hi! I think this will turn out to be a dumb question, but I can’t seem to get the post request to the Iglu server to work. I’m trying with the first example on the setup guide.

curl iglu-lb-<ACCOUNT>.<REGION>.elb.amazonaws.com/api/schemas -X POST -H "apikey: <WRITE_KEY>" -d '{"json": {"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", "description": "Schema for an Acme Inc ad click event", "self": {"vendor": "com.acme", "name": "ad_click","format": "jsonschema","version": "1-0-0"},"type": "object","properties": {"clickId": {"type": "string"},"targetUrl": {"type": "string","minLength": 1}},"required": ["targetUrl"],"additionalProperties": false}}'

{“message”:“The request body was invalid.”}%

All debug checks passes

Loading the same json in Python checks out. What am I doing wrong?

>>> import json
>>> json.loads("""{"json": {"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", "description": "Schema for an Acme Inc ad click event", "self": {"vendor": "com.acme", "name": "ad_click","format": "jsonschema","version": "1-0-0"},"type": "object","properties": {"clickId": {"type": "string"},"targetUrl": {"type": "string","minLength": 1}},"required": ["targetUrl"],"additionalProperties": false}}""")
{'json': {'$schema': 'http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#', 'description': 'Schema for an Acme Inc ad click event', 'self': {'vendor': 'com.acme', 'name': 'ad_click', 'format': 'jsonschema', 'version': '1-0-0'}, 'type': 'object', 'properties': {'clickId': {'type': 'string'}, 'targetUrl': {'type': 'string', 'minLength': 1}}, 'required': ['targetUrl'], 'additionalProperties': False}}

I also tried setting the vendor to the same vendor as in the debug response

{"version":"0.7.0","authInfo":{"vendor":"<OURVENDOR>","schema":"READ","key":[]},"database":"postgres","schemaCount":0,"debug":false,"patchesAllowed":true}

Somewhat related, this is where the custom contexts go in the end? A custom context is a type of “self-describing schema”?

Hi @medicinal-matt

In your request payload, the schema is nested in a "json" sub-field, which is not correct. I can see you copied this example from the documentation page - so I think we need to fix the documentation because it is misleading.

I got your example to work by running this:

curl -XPOST localhost:8080/api/schema -H "apikey: <WRITE_KEY>" -d '{"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", "description": "Schema for an Acme Inc ad click event", "self": {"vendor": "com.acme", "name": "ad_click","format": "jsonschema","version": "1-0-0"},"type": "object","properties": {"clickId": {"type": "string"},"targetUrl": {"type": "string","minLength": 1}},"required": ["targetUrl"],"additionalProperties": false}'

Sorry for the confusion with the docs!

1 Like

Thanks! I thought it was a strange format, but that was the documentation. Changing it solved the issue

@istreeter: Could you also confirm that this is where the custom contexts go in the end? A custom context is a type of “self-describing schema”?

Correct - custom events and context schemas are all self-decsribing schemas, uploading them to Iglu is the same process for both. Note that this means you shouldn’t give events and contexts the same name, this would cause problems at loading stage (since contexts are arrays and events are single objects).

1 Like