parameters for google cloud natural language api
<p>I want to use pure http requests to get the result from google cloud natural language api, but their document does not specify the parameter names.</p>

<p>Here is my python code:</p>

<pre><code>import requests
url = "https://language.googleapis.com/v1beta1/documents:analyzeEntities"
d = {"document": {"content": "some text here", "type": "PLAIN_TEXT"}}
para = {"key": "my api key"}
r = requests.post(url, params=para, data=d)
</code></pre>

<p>Here is the error message:
<code>{u'error': {u'status': u'INVALID_ARGUMENT', u'message': u'Invalid JSON payload received. Unknown name "document": Cannot bind query parameter. \'document\' is a message type. Parameters can only be bound to primitive types.', u'code': 400, u'details': [{u'fieldViolations': [{u'description': u'Invalid JSON payload received. Unknown name "document": Cannot bind query parameter. \'document\' is a message type. Parameters can only be bound to primitive types.'}], u'@type': u'type.googleapis.com/google.rpc.BadRequest'}]}}
</code></p>

<p>how should I create the http request without using their python library?</p>

<p>ok, I figured it out. I need to pass JSON-Encoded POST/PATCH data, so the request should be <code>r = requests.post(url, params=para, json=d)</code></p>

python rest google-api google-cloud-platform