+<td>If <code>Params</code> is not empty, its interpretation is dependent on <code>Command</code> and the content type of the request. The content type is determined by the <a href="#request-settings-contenttype"><code>ContentType</code></a> setting or the presence of a <code>content-type</code> header.<br/><br/>If <code>Command</code> is <code>'GET'</code> or <code>'HEAD'</code>, the request will generally not have a payload in the message body (and hence no specified content type) and <code>Params</code> will be URLEncoded if necessary and appended to the query string of <code>URL</code>.<br/><br/>If <code>Command</code> is neither <code>'GET'</code> nor <code>'HEAD'</code> and no content type has been specified, <code>HttpCommand</code> will attempt to infer the content type as follows:<ul><li>If <code>Params</code> is a simple character vector and looks like JSON <code>HttpCommand</code> will set the content type as <code>'application/json'</code>; otherwise it will set the content type to <code>`application/x-www-form-urlencoded'</code>. <code>Params</code> will then be processed as described below.</li><li>Otherwise <code>HttpCommand</code> will set the content type to <code>'application/json'</code> and <code>Params</code> will be processed as described below.</li></ul>If the content type is specified, <code>Params</code> is processed based on the content type and inserted as the payload of the request. If the content type is:<ul><li><code>'x-www-form-urlencoded'</code>: <code>Params</code> will be formatted using <a href="#encode-methods-urlencode"><code>URLEncode</code></a> unless it already composed completely of valid URLEncoding characters.</li><li><code>'application/json'</code>:<ul><li>If <code>Params</code> is a character vector that is a valid JSON representation, it is left unaltered.</li><li>Otherwise <code>Params</code> will be converted to JSON format using <code>1 ⎕JSON</code>.</li><li>In the case where <code>Params</code> is an APL character vector that is also valid JSON, you should convert it to JSON prior to setting <code>Params</code>. For example, if you have the character vector <code>'[1,2,3]'</code> and you want it treated as a string in JSON and not the numeric array <code>[1,2,3]</code>, you should process it yourself using <code>1 ⎕JSON</code>.</li></ul></li><li>For any other content type, it is the responsibility of the user to format <code>Params</code> appropriately for that content type.</li></ul>Normally, request parameters will reside either in the query string of the URL (as in the case of a <code>GET</code> or <code>HEAD</code> request), or in the request's payload (for other types of HTTP requests). In the rare case where you need to provide parameters in BOTH the query string AND the payload, you will need to construct and append the query string to the URL yourself. For example:<br><pre style="font-family:APL;"> h.URL←'someplace.com?',h.URLEncode ('this' 'that')('query' 'true')<br> h.Params←('name' 'daffy')('species' 'duck')<br> h.Show<br>POST /?this=that&query=true HTTP/1.1<br>Host: someplace.com<br>User-Agent: Dyalog-HttpCommand/5.9.4<br>Accept: <em>/</em><br>Accept-Encoding: gzip, deflate<br>Content-Type: application/json;charset=utf-8<br>Content-Length: 37<br><br>[["name","daffy"],["species","duck"]]</pre></td>
0 commit comments