Ask Your Question

How to import XMLHttpRequest module in JavaScript processor

asked 2019-07-05 17:52:45 -0500

sam gravatar image

I need to send a HTTP post request using a JavaScript processor. My code looks like this:

var xhr = new XMLHttpRequest();
var url = "url";"POST", url, true);
xhr.onreadystatechange = function () {
    if (xhr.readyState === 4 && xhr.status === 200) {
        var json = JSON.parse(xhr.responseText);
        console.log("Successfully ingested the batch " + json);
var data = JSON.stringify(payload);

On previewing, I get the below error:

"com.streamsets.pipeline.api.base.OnRecordErrorException: SCRIPTING_04 - Script sent record to error: ReferenceError: "XMLHttpRequest" is not defined"

As I understand, there is no such thing as importing modules in JavaScript, how do I use modules like XMLHttpRequest? Please guide. Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-07-10 12:13:31 -0500

iamontheinet gravatar image

Hi Sam,

XMLHttpRequest is a web browser's JS environment object used for transferring data between browser and a web server; completely and very different from when you're working within SDC.

To initiate HTTP requests from SDC, you should look into HTTP Client origin and HTTP Client processor.

Cheers, Dash

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-07-05 17:46:58 -0500

Seen: 370 times

Last updated: Jul 10