# Crowdsourcing Example

{% hint style="info" %}
Please read the [Quick Start](/implementation-guides/quick-start.md) guide to understand the basics of MRS first.
{% endhint %}

In order to call the /crowdsourcing endpoint, and report user feedback (see [Overview](/advanced-use-cases/crowdsourcing/overview.md)):

#### Required Fields

In the `/merchant/list` and `/merchant` endpoints, the `X-Request-Id` and `X-Timestamp` headers are returned. In order to submit a crowdsourcing request, you must store these values and send them in the `requestId` and `requestTimstamp` fields. If the report is in relation to a transaction in a `/merchant/list` request, you must also include the `transactionId` field of that transaction.

More on this in the OpenAPI spec.

{% tabs %}
{% tab title="cURL" %}
`curl --request POST`\
`--url https://`**`regional-snowdrop-domain-goes-here.com`**`/api/v3/crowdsourcing`\
`--header 'Content-Type: application/json'`\
`--header 'X-Api-Key:`` `**`<YOUR-API-KEY>`**`'`\
`--data '{ "requestId": "1234abcd-1234-1234-1234-1234567890abc", "requestTimestamp": 1663766866877, "transactionId": "1234x1234", "wrongFields": [ "name", "address", "img" ], "suggestions": { "name": "McDonalds", "address":"10 Downing Street", "img": "new_logo.url" } }'`
{% endtab %}

{% tab title="Python" %}
`import http.client`

`conn = http.client.HTTPSConnection("`**`regional-snowdrop-domain-goes-here.com`**`")`

`payload = "{"requestId": "1234abcd-1234-1234-1234-1234567890abc","requestTimestamp": 1663766866877,"transactionId": "218x09d","wrongFields": ["name","address","img"],"suggestions": {"name": "McDonalds","address":"10 Downing Street","img": "new_logo.url"}}"`

`headers = { 'Content-Type': "application/json", 'X-Api-Key': "`**`<YOUR-API-KEY>`**`" }`

`conn.request("POST", "/api/v3/crowdsourcing", payload, headers)`

`res = conn.getresponse() data = res.read()`

`print(data.decode("utf-8"))`
{% endtab %}

{% tab title="C#" %}
`var client = new RestClient("https://`**`regional-snowdrop-domain-goes-here.com`**`/api/v3/crowdsourcing");`&#x20;

`var request = new RestRequest(Method.POST);`

`request.AddHeader("Content-Type", "application/json"); request.AddHeader("X-Api-Key", "`**`<YOUR-API-KEY>`**`"); request.AddParameter("application/json", "{"requestId": "1234abcd-1234-1234-1234-1234567890abc","requestTimestamp": 1663766866877,"transactionId": "218x09d","wrongFields": ["name","address","img"],"suggestions": {"name": "McDonalds","address":"10 Downing Street","img": "new_logo.url"}}", ParameterType.RequestBody);`

`IRestResponse response = client.Execute(request);`
{% endtab %}

{% tab title="Javascript" %}
`const data = JSON.stringify({ "requestId": "1234abcd-1234-1234-1234-1234567890abc", "requestTimestamp": 1663766866877, "transactionId": "218x09d", "wrongFields": [ "name", "address", "img" ], "suggestions": { "name": "McDonalds", "address": "10 Downing Street", "img": "new_logo.url" } });`

`const xhr = new XMLHttpRequest();`&#x20;

`xhr.withCredentials = true;`

`xhr.addEventListener("readystatechange", function () {`&#x20;

&#x20;   `if (this.readyState === this.DONE) {`

&#x20;       `console.log(this.responseText);`&#x20;

&#x20;   `}`

`});`

`xhr.open("POST", "https://`**`regional-snowdrop-domain-goes-here.com`**`/api/v3/crowdsourcing");`&#x20;

`xhr.setRequestHeader("Content-Type", "application/json");`&#x20;

`xhr.setRequestHeader("X-Api-Key", "`**`<YOUR-API-KEY>`**`");`

`xhr.send(data);`
{% endtab %}

{% tab title="Java" %}
`HttpResponse response = Unirest.post("`**`https://regional-snowdrop-domain-goes-here.com`**`/api/v3/crowdsourcing") .header("Content-Type", "application/json") .header("X-Api-Key", "`**`<YOUR-API-KEY>`**`") .body("{"requestId": "1234abcd-1234-1234-1234-1234567890abc","requestTimestamp": 1663766866877,"transactionId": "218x09d","wrongFields": ["name","address","img"],"suggestions": {"name": "McDonalds","address":"10 Downing Street","img": "new_logo.url"}}") .asString();`
{% endtab %}
{% endtabs %}

#### Response

If you supplied the required fields correctly, you should recieve a success message:

```
{
    "message": "Report created"
}
```

Having problems? Consult [Troubleshooting](/troubleshooting.md) or [FAQ](/faq.md).


---

# 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://devs.snowdropsolutions.co.uk/advanced-use-cases/crowdsourcing/crowdsourcing-example.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.
