Sream direct video upload: bad request

I converted he code given in cloudflare stream direct video upload section to below node.js code, but I get a ‘Bad request’ response.

Request:

var request = require(‘request’);
var options = {
‘method’: ‘POST’,
‘url’: ‘https://api.cloudflare.com/client/v4/accounts/$accountid/stream/direct_upload’,
‘headers’: {
‘Authorization’: ‘Bearer $token’,
},
form: {
‘{\n “maxDurationSeconds”: 3600,\n “expiry”: “2021-03-12T22:20:00Z”,\n “requireSignedURLs”: true\n }’: ‘’
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});

Response:

{
“result”: null,
“success”: false,
“errors”: [
{
“code”: 10005,
“message”: “Bad Request”
}
],
“messages”: null
}

Please help me send the proper request.

Regards.

I am not familiar with the way you’re constructing a request but I believe you need to set the body of the request to the JSON structure instead of using the form field.