# Generic HTTP Adapter

This is a generic HTTP adapter that can connect with a variety of different systems using the Python requests library.

## Adapter Config <a href="#generichttpadapter-adapterconfig" id="generichttpadapter-adapterconfig"></a>

| Field                 | Description                                                                                                      | Example                                                                                                                                                                                                                                                                                                                                                           |
| --------------------- | ---------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Host`                | REQUIRED                                                                                                         | <p>Host of web server (note: web server is expected to use “https”).</p><p>The adapter assumes HTTPS is to be used. Unsecure HTTP is not supported.</p><p>Do not include any path components besides the domain name of the host (use <code>[www.example.com](http://www.example.com)</code> <em>not</em> <code><https://www.example.com/some/path></code>)</p>   |
| `Basic Auth Username` | OPTIONAL                                                                                                         | <p>Username for authenticating with remote host.</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#basic_authentication_scheme">Mozilla docs: HTTP authentication - Basic authentication scheme</a></p>                                                                                                                             |
| `Basic Auth Password` | OPTIONAL \| Password for authenticating with remote host.                                                        | `*********`                                                                                                                                                                                                                                                                                                                                                       |
| `Server Auth Cert`    | OPTIONAL                                                                                                         | <p>Certificate used to verify the identity of the remote server.</p><p>Certificates can come in many filetypes: <code>.der</code>, <code>.cer</code>, <code>.crt</code>, <code>.cert</code>, <code>.pem</code>, <code>.p12</code>, <code>.pfx</code></p><p>Password protected <code>.pfx</code> / <code>.p12</code> certificates are not currently supported.</p> |
| `Client Auth Cert`    | OPTIONAL \| Certificate used to verify the identity of the requestor (Integration Gateway) to the remote server. | `client_certificate.pem`                                                                                                                                                                                                                                                                                                                                          |
| `Timeout Seconds`     | REQUIRED \| The number of seconds before the connection should time out. Min 1, max 120, default 60.             | 60                                                                                                                                                                                                                                                                                                                                                                |

## Field Mappings <a href="#generichttpadapter-fieldmappings" id="generichttpadapter-fieldmappings"></a>

<table><thead><tr><th>Field</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>url_path</code></td><td>REQUIRED | <code>str</code> | URL path to use with host.</td><td><code>'/test/example'</code></td></tr><tr><td><code>method</code></td><td>REQUIRED | <code>str</code> | HTTP method to use in request.</td><td><code>'POST'</code></td></tr><tr><td><code>body</code></td><td><p>OPTIONAL | <code>multiple types</code> | Payload in the request.</p><p>Setting a <code>dict</code> as the value will make the adapter set the <code>Content-Type</code> header to <code>application/x-www-form-urlencoded</code>.</p><p>To send JSON data, import the <code>json</code> module and use <code>json.dumps(value)</code>.</p></td><td><p>JSON: <code>json.dumps({'key': "value"})</code></p><p>Form data: <code>{'key': "value"}</code></p></td></tr><tr><td><code>params</code></td><td>OPTIONAL | <code>dict</code> | Key-value pairs to send as query parameters.</td><td><p><code>{'search': "foo", 'page': "3"}</code></p><p><code>params.search : "foo"</code></p><p><code>params.page : "3"</code></p><p>Resulting URL: <code>https://www.example.com/url/path?search=foo,page=3</code></p></td></tr><tr><td><code>headers</code></td><td><p>OPTIONAL | <code>dict</code> | Key-value pairs representing headers for the request.</p><p>Consider using the <code>Content-Type</code> header to tell the remote host the type of content you are sending and/or the <code>Accept</code> header to tell the remote server what type of content you are willing/able to receive.</p><p>Hyphens do not work with <code>dot.notation</code> so please use <code>['bracket-notation']</code> in this case.</p><p>References</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type">Mozilla docs: Content-Type</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept">Mozilla docs: Accept</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types">Mozilla docs: Common MIME types (Content Types)</a>,</li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation">Mozilla docs: HTTP Content negotiation</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers">Mozilla docs: HTTP headers</a></li></ul></td><td><pre><code>{
  'Content-Type': "application/xml",
  'Accept': "application/xml",
  'Some-Custom-Header': "Some custom value"
}
</code></pre><p><code>headers['Content-Type'] : "application/json"</code></p><p><code>headers.Accept : "application/octet-stream"</code></p></td></tr><tr><td><code>auth</code></td><td><p>OPTIONAL | <code>tuple</code> | Username and password used for basic authentication.</p><p>This overrides the Adapter Config Basic Auth Username and Password and <strong>should only be used in special circumstances</strong>.</p><p>For more info, please see <a href="https://requests.readthedocs.io/en/latest/user/authentication/#basic-authentication">the documentation</a> on <code>requests</code> Basic Authentication features.</p></td><td><code>('username', 'p@$$w0rd')</code></td></tr><tr><td><code>force_response_content_type</code></td><td><p>OPTIONAL | <code>str</code> | Force the adapter to parse the response content in a certain way.</p><p>If not specified, the adapter dynamically parses the response according to its <code>Content-Type</code> header.<br>This optional field is likely unnecessary, but is nonetheless available for unique circumstances that may arise.</p><ul><li><p><code>"json"</code> | Adapter will parse the response as JSON, regardless of the response <code>Content-Type</code> header.</p><ul><li>Returns JSON-like Python object, usually <code>dict</code>, <code>list</code>, but possibly <code>str</code>, <code>int</code> or <code>float</code>.</li></ul></li><li><p><code>"xml"</code> | Adapter will parse the response as XML, regardless of the response <code>Content-Type</code> header.</p><ul><li>Returns a <code>dict</code> representing the XML data structure, following the same standard as most (if not all) Integration Gateway XML adapters.</li></ul></li><li><p><code>"text"</code> | Adapter will parse the response as plaintext, regardless of the response <code>Content-Type</code> header.</p><ul><li>Returns a <code>str</code>.</li></ul></li><li><p><code>"bytes"</code> | Adapter will parse the response as binary data, regardless of the response <code>Content-Type</code> header.</p><ul><li>Returns <code>bytes</code></li></ul></li></ul><p>Using <code>"json"</code> will call the <code>requests</code> <code>Response.json()</code> method when parsing the response, and <strong>will raise an exception</strong> if the response is not valid JSON, causing the Service Request to <strong>fail</strong>.</p><p>Using <code>"xml"</code> will call the <code>django_glyue_app.utils.xml_to_adapter_payload()</code> method when parsing the response, and <strong>will raise an exception</strong> if the response is not valid XML, causing the Service Request to <strong>fail</strong>.</p><p>Using <code>"text"</code> or <code>"bytes"</code> should never raise an exception, and generally safe to use in all circumstances.</p></td><td><p><code>"json"</code></p><p><code>"xml"</code></p><p><code>"text"</code></p><p><code>"bytes"</code></p></td></tr></tbody></table>

#### Additional Information: <a href="#generichttpadapter-additionalinformation" id="generichttpadapter-additionalinformation"></a>

the adapter attempts to parse the relevant content for the user based on the ‘content-type’ response header. These align with the `force_response_content_type` on the field mappings.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://glyue.docs.sandboxbanking.com/reference/adapters/generic-http-adapter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
