<p><strong>Postdata</strong> must be String, not Object. ('tx_hex=...')</p>

CC BY-SA 4.0
2018-05-30T10:18:04.773Z
2018-05-30T10:18:04.773Z
Дима Марков
<p>I have raw data (tx_hex) for raw transaction, but I cant send it to litecoin tesnet using post request to testnet.litecore.api. If I insert tx_hex manually in the browser, the transaction is correctly sent. My code: </p>

<pre><code>request({
    url: 'https://testnet.litecore.io/tx/send',
    method: 'POST',
    data: test_tx
}, ((error, response, body) =&gt; {
    if(error) {
        console.log(error);
    } else {
        console.log(body);
    }
}));
</code></pre>

<p>I also tried to use another service, but it's failing too.</p>

<p>Code :</p>

<pre><code>postdata = { tx_hex : test_tx };
request.post('https://chain.so/api/v2/send_tx/LTCTEST', postdata, function 
             optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log('Upload successful!  Server responded with:', body);
});
</code></pre>

CC BY-SA 4.0
2018-05-25T14:56:19.550Z
Does it give you an error message on failing?
Raghav Sood
CC BY-SA 4.0
2018-05-29T07:32:07.123Z
It return html-page with "Cannot POST to /tx/send".
Дима Марков
CC BY-SA 4.0
2018-05-29T07:40:18.427Z
From what I recall, the POST is supposed to be sent to the api /tx/send endpoint, which depends on your insight API prefix (it's usually /api or /insight-api)
Raghav Sood
<transactions><litecoin><raw-transaction><raw-data><sendrawtransaction>
Send raw transaction (have tx_hex) on litecoin testnet using api or module
Дима Марков
# Send raw transaction (have tx_hex) on litecoin testnet using api or module

(Asked by: username_0 on 2018-05-25)

I have raw data (tx_hex) for raw transaction, but I cant send it to litecoin tesnet using post request to testnet.litecore.api. If I insert tx_hex manually in the browser, the transaction is correctly sent. My code: 
request({
    url: 'https://testnet.litecore.io/tx/send',
    method: 'POST',
    data: test_tx
}, ((error, response, body) => {
    if(error) {
        console.log(error);
    } else {
        console.log(body);
    }
}));

I also tried to use another service, but it's failing too.
Code :
postdata = { tx_hex : test_tx };
request.post('https://chain.so/api/v2/send_tx/LTCTEST', postdata, function 
             optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log('Upload successful!  Server responded with:', body);
});

**Tags:** transactions, litecoin, raw-transaction, raw-data, sendrawtransaction

> **Comments:**
> **username_1**: Does it give you an error message on failing?  
> **username_0**: It return html-page with "Cannot POST to /tx/send".  
> **username_1**: From what I recall, the POST is supposed to be sent to the api /tx/send endpoint, which depends on your insight API prefix (it's usually /api or /insight-api)  

---

## 1 answers

### Answer by username_0 on 2018-05-30. Score: 1 | Accepted answer

**Postdata** must be String, not Object. ('tx\_hex=...')


---

