> For the complete documentation index, see [llms.txt](https://docs.scrapingdog.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scrapingdog.com/post-request.md).

# POST Request

You can also send a POST request through Scrapingdog API along with the headers and the data you want to submit to another API or a form.&#x20;

### Usage

{% tabs %}
{% tab title="cURL" %}

```bash
url -d 'foo=bar' \
    -X POST \
    "https://api.scrapingdog.com/scrape?api_key=5e5a97e5b1ca5b194f42da86c5e27dd646&url=http://httpbin.org/anything"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.scrapingdog.com/scrape?api_key=5e5a97e5b1ca5b194f42da86c5e27dd646&url=http://httpbin.org/anything"
data = {"foo": "bar"}

response = requests.post(url, data=data)

print(response.text)

```

{% endtab %}

{% tab title="Nodejs" %}

```javascript
const axios = require('axios');

const url = 'https://api.scrapingdog.com/scrape?api_key=5e5a97e5b1ca5b194f42da86c5e27dd646&url=http://httpbin.org/anything';
const data = { foo: 'bar' };

axios.post(url, data)
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error(error);
  });

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$api_key = '5e5a97e5b1ca5b194f42da86c5e27dd646';
$url = 'http://httpbin.org/anything';

$data = array('foo' => 'bar');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.scrapingdog.com/scrape?api_key=' . $api_key . '&url=' . $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
}

curl_close($ch);

echo $response;
?>

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'uri'

api_key = '5e5a97e5b1ca5b194f42da86c5e27dd646'
url = 'http://httpbin.org/anything'

uri = URI.parse("https://api.scrapingdog.com/scrape?api_key=#{api_key}&url=#{url}")

data = { 'foo' => 'bar' }

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data(data)

response = http.request(request)

puts response.body

```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "5e5a97e5b1ca5b194f42da86c5e27dd646";
            String url = "http://httpbin.org/anything";

            URL apiUrl = new URL("https://api.scrapingdog.com/scrape?api_key=" + apiKey + "&url=" + url);

            HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
            connection.setRequestMethod("POST");

            Map<String, String> parameters = new HashMap<>();
            parameters.put("foo", "bar");

            connection.setDoOutput(true);
            OutputStream os = connection.getOutputStream();
            os.write(getParamsString(parameters).getBytes());
            os.flush();
            os.close();

            int responseCode = connection.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                // Request was successful
                // Process the response here
            } else {
                // Request failed
                System.out.println("Request failed with response code: " + responseCode);
            }

            connection.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static String getParamsString(Map<String, String> params) {
        StringBuilder result = new StringBuilder();

        for (Map.Entry<String, String> entry : params.entrySet()) {
            if (result.length() > 0) {
                result.append("&");
            }
            result.append(entry.getKey());
            result.append("=");
            result.append(entry.getValue());
        }

        return result.toString();
    }
}

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.scrapingdog.com/post-request.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.
