# Update Results of Approved Invoices with QuickBooks Enterprise Response

Endpoint Name: `updateqbestatus`

Endpoint Details:This API is used to get the results of approved invoices which are approved by the approver of a company using date range filter, QBE status filter and username list.

Authorization: Bearer token as header

### Request Type

<table data-header-hidden><thead><tr><th width="112"></th><th></th></tr></thead><tbody><tr><td>Method</td><td>URL</td></tr><tr><td>POST</td><td><code>URL/access/klearstack/updateqbestatus</code></td></tr></tbody></table>

### Request Body

<table data-header-hidden><thead><tr><th width="95"></th><th width="163"></th><th width="93"></th><th></th></tr></thead><tbody><tr><td>Type</td><td>Params</td><td>Values</td><td>Description</td></tr><tr><td>POST</td><td>company_name</td><td>string</td><td><p>Name of the company</p><p><br></p></td></tr><tr><td>POST</td><td>username</td><td>string</td><td>Username for a particular user of a company</td></tr><tr><td>POST</td><td>password</td><td>string</td><td>Password for a particular user of a company</td></tr><tr><td>POST</td><td>document_type</td><td>string</td><td><p>Type of document to be processed - “Invoices”, “Receipts”, “PurchaseOrders”,“NACH”,“LoanAgreement” or “Insurances”.</p><p>By default “Invoices” will be set if this parameter is not passed</p><p>Note: Optional Parameter</p></td></tr><tr><td>POST</td><td>QBE_response</td><td>string</td><td><p>Response of Quickbook to particular invoice.This will be a string of Json.</p><p>Ex. </p><p>“{"document_id":"6073ff72de02f2c94bca9cef","QBE_status": "successful","error_message": "ErrMsg","QBE_timestamp":"14/04/2021 12:32:49"}“</p></td></tr></tbody></table>

### Shell (cURL)

* Request Body

```sh
curl --location POST "URL/access/klearstack/updateqbestatus" \
  --header "Authorization: Bearer your_token_here" \
  --form "company_name=Replace_Company_Name_Here" \
  --form "username=Replace_User_Name_Here" \
  --form "password=Replace_Password_Here" \
  --form "document_type=Invoices" \
  --form 'QBE_response={
    "document_id":"6073ff72de02f2c94bca9cef",
    "QBE_status":"successful",
    "error_message":"ErrMsg",
    "QBE_timestamp":"14/04/2021 12:32:49"
  }'
```

### Python

* Request Body

```python
import requests

# API URL
url = "URL/access/klearstack/updateqbestatus"

# Request payload
data = {
    "company_name": "Replace_Company_Name_Here",
    "username": "Replace_User_Name_Here",
    "password": "Replace_Password_Here",
    "document_type": "Invoices",
    "QBE_response": '{"document_id":"6073ff72de02f2c94bca9cef","QBE_status": "successful","error_message": "ErrMsg","QBE_timestamp":"14/04/2021 12:32:49"}'
}

# Headers
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer your_token_here"
}

# Make the POST request
response = requests.post(url, json=data, headers=headers)

# Print the response
if response.status_code == 200:
    print(response.json())
else:
    print("Error:", response.text)
```

### Java

* Request Body

```java
import okhttp3.*;

import java.io.IOException;

public class UpdateQBEStatusAPI {
    public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();

        // JSON payload
        String jsonPayload = "{ \"company_name\": \"Replace_Company_Name_Here\", " +
                "\"username\": \"Replace_User_Name_Here\", " +
                "\"password\": \"Replace_Password_Here\", " +
                "\"document_type\": \"Invoices\", " +
                "\"QBE_response\": \"{\\\"document_id\\\":\\\"6073ff72de02f2c94bca9cef\\\",\\\"QBE_status\\\": \\\"successful\\\",\\\"error_message\\\": \\\"ErrMsg\\\",\\\"QBE_timestamp\\\":\\\"14/04/2021 12:32:49\\\"}\" }";

        RequestBody body = RequestBody.create(
            jsonPayload, MediaType.parse("application/json"));

        Request request = new Request.Builder()
            .url("URL/access/klearstack/updateqbestatus")
            .post(body)
            .addHeader("Content-Type", "application/json")
            .addHeader("Authorization", "Bearer your_token_here")
            .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                System.out.println("Response: " + response.body().string());
            } else {
                System.out.println("Error: " + response.body().string());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
```

### Node.js

* Request Body

```javascript
var request = require('request');

const form_data = {
  'company_name': 'Replace_Company_Name_Here',
  'username': 'Replace_User_Name_Here',
  'password': 'Replace_Password_Here',
  'document_type': 'Invoices',
  'QBE_response': '{"document_id":"6073ff72de02f2c94bca9cef","QBE_status": "successful","error_message": "ErrMsg","QBE_timestamp":"14/04/2021 12:32:49"}'
};

const options = {
  url: 'URL/access/klearstack/updateqbestatus',
  json: form_data,
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_token_here'
  }
};

request.post(options, function(err, httpResponse, body) {
  if (err) {
    console.error('Request failed:', err);
    return;
  }

  console.log('Response:', body);
});
```

### JavaScript (Browser)

* Request Body

```javascript
var payload = JSON.stringify({
    company_name: "Replace_Company_Name_Here",
    username: "Replace_User_Name_Here",
    password: "Replace_Password_Here",
    document_type: "Invoices",
    QBE_response: "{\"document_id\":\"6073ff72de02f2c94bca9cef\",\"QBE_status\": \"successful\",\"error_message\": \"ErrMsg\",\"QBE_timestamp\":\"14/04/2021 12:32:49\"}"
});

var xhr = new XMLHttpRequest();
xhr.open("POST", "URL/access/klearstack/updateqbestatus", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer your_token_here");

// Handle response
xhr.onreadystatechange = function () {
    if (xhr.readyState === XMLHttpRequest.DONE) {
        if (xhr.status === 200) {
            console.log("Response:", xhr.responseText);
        } else {
            console.error("Error:", xhr.responseText);
        }
    }
};

// Send request
xhr.send(payload);
```

### API Response

<table data-header-hidden><thead><tr><th width="112"></th><th></th></tr></thead><tbody><tr><td>Status</td><td>Example Response</td></tr><tr><td>200</td><td>“QBE status updated successfully”</td></tr><tr><td>200</td><td><p>if document id is not found.</p><p>“Document ID not found”</p></td></tr></tbody></table>
