---
description: API endpoints available for interacting with Service Requests.
---

# Service Requests

## List Service Requests

<mark style="color:blue;">`GET`</mark> `https://muni-portal-backend.openup.org.za/api/service-requests/`

Retrieve a list of Service Request objects that belong to the user making the request.

{% tabs %}
{% tab title="200 Successful response with multiple objects" %}
```python
[
    {
        "id": 3,
        "collaborator_object_id": 556706,
        "type": "Roads",
        "user_name": "Mr Test",
        "user_surname": "Surname",
        "user_mobile_number": "0792816737",
        "user_email_address": "user@example.com",
        "municipal_account_number": null,
        "street_name": "Geen Straat",
        "street_number": "123",
        "suburb": "Daar",
        "description": "Iets is fout",
        "coordinates": null,
        "request_date": "2020-01-01",
        "mobile_reference": "12345",
        "on_premis_reference": "373834",
        "status": "Registered",
        "demarcation_code": "WC033",
        "user": 1
    },
    {
        "id": 2,
        "collaborator_object_id": 556705,
        "type": "Sewerage",
        "user_name": "Mr JD",
        "user_surname": "Bothma",
        "user_mobile_number": "0792816737",
        "user_email_address": "jd@openup.org.za",
        "municipal_account_number": null,
        "street_name": "Geen Straat",
        "street_number": "123",
        "suburb": "Daar",
        "description": "This one has the date 2020-02-04 sent from the app",
        "coordinates": "12.3, 45.6",
        "request_date": "2020-02-04",
        "mobile_reference": null,
        "on_premis_reference": "373762",
        "status": "Assigned",
        "demarcation_code": "WC033",
        "user": 1
    },
    {
        "id": 1,
        "collaborator_object_id": 556704,
        "type": "Sewerage",
        "user_name": "Mr JD",
        "user_surname": "Bothma",
        "user_mobile_number": "0792816737",
        "user_email_address": "jd@openup.org.za",
        "municipal_account_number": null,
        "street_name": "Geen Straat",
        "street_number": "123",
        "suburb": "Daar",
        "description": "This one has the date 2020-02-01 sent from the app",
        "coordinates": "12.3, 45.6",
        "request_date": "2020-02-01",
        "mobile_reference": null,
        "on_premis_reference": "373761",
        "status": "Assigned",
        "demarcation_code": "WC033",
        "user": 1
    }
]
```
{% endtab %}
{% endtabs %}

## Detail Service Request

<mark style="color:blue;">`GET`</mark> `https://muni-portal-backend.openup.org.za/api/service-requests/:id/`

Retrieve detail about a Service Request object.

#### Path Parameters

| Name | Type    | Description                       |
| ---- | ------- | --------------------------------- |
| id   | integer | Service Request object identifier |

{% tabs %}
{% tab title="200 Successful response if the object was found." %}
```
{
    "id": 1,
    "collaborator_object_id": 556704,
    "type": "Sewerage",
    "user_name": "Mr JD",
    "user_surname": "Bothma",
    "user_mobile_number": "0792816737",
    "user_email_address": "jd@openup.org.za",
    "municipal_account_number": null,
    "street_name": "Geen Straat",
    "street_number": "123",
    "suburb": "Daar",
    "description": "This one has the date 2020-02-01 sent from the app",
    "coordinates": "12.3, 45.6",
    "request_date": "2020-02-01",
    "mobile_reference": null,
    "on_premis_reference": "373761",
    "status": "Assigned",
    "demarcation_code": "WC033",
    "user": 1
}
```
{% endtab %}

{% tab title="404 Fail response if the object was not found." %}
```
{
    "detail": "Not found."
}
```
{% endtab %}
{% endtabs %}

## Create Service Request

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/service-requests/`

Create a Service Request object. \
\
The object is not visible in List or Detail views until it has successfully been created in Collaborator Web API. \
\
If the object does show up in List or Detail views, it has successfully been created in Collaborator Web API and will have the status "created."

#### Request Body

| Name                 | Type   | Description                                                           |
| -------------------- | ------ | --------------------------------------------------------------------- |
| coordinates          | string | Latitude, Longitude as Decimal Degrees e.g. `-34.8161234, 19.9712024` |
| description          | string | Description                                                           |
| suburb               | string | Suburb (We supply Town in this field)                                 |
| street\_number       | string | Street number                                                         |
| street\_name         | string | Street name                                                           |
| user\_mobile\_number | string | Mobile number                                                         |
| user\_surname        | string | Surname                                                               |
| user\_name           | string | First name                                                            |
| type                 | string | Type (Service Area)                                                   |

{% tabs %}
{% tab title="201 " %}
```
{}
```
{% endtab %}
{% endtabs %}
