HTTP Request - Matching functionality to Win 10 cURL request

Hi -

Very new to this word, working through a examples and building up some functionality as I learn so thank you in advance.

I am pulling a list of cameras from a video server as a "building block". I started verifying that I could reach the server and make the API call using cURL (Win 10) first. This was successful and passes credentials with the request and uses the -k option to ignore the local self signed cert. The credentials are in the screen shot below, but are only for a local test server so no risk or danger.

C:\Windows\system32>curl https://192.168.2.250/api/cameras -k -u cold:beer

Now moving into Node-RED, I am attempting to emulate this functionally using using an HTTP Request node.

  • I have placed a change node in front of the HTTP request node with set the rejectUnauthorized to False to ignore the SSL rejection. (-k option cURL)
  • I have set the url in the HTTP Request to https://192.168.2.250/api/cameras matching that of the cURL request
  • I have entered the credentials and selected basic authentication

It does not return the data instead I receive this msg.payload : string[3024] "{"message":"Unable to locate view \u0027ListResponseDto1\u0027\r\nCurrently available view engine extensions: sshtml,html,htm,cshtml,vbhtml\r\nLocations inspected: views/api/cameras/Cameras/ListResponseDto1-en-US,views/api/cameras/Cameras/ListResponseDto1,api/cameras/Cameras/ListResponseDto1-en-US,api/cameras/Cameras/ListResponseDto1,views/api/cameras/ListResponseDto1-en-US,views/api/cameras/ListResponseDto1,api/cameras/ListResponseDto1-en-US,api/cameras/ListResponseDto1,views/Cameras/ListResponseDto1-en-US,views/Cameras/ListResponseDto1,Cameras/ListResponseDto1-en-US,Cameras/ListResponseDto1,views/ListResponseDto1-en-US,views/ListResponseDto1,ListResponseDto1-en-US,ListResponseDto1\r\nRoot path: C:\Program Files\Senstar\Symphony Server v7\_bin\\r\nIf you were expecting raw data back, make sure you set the \u0027Accept\u0027-header of the request to correct format, for example \u0027application/json\u0027","exception":"Nancy.ViewEngines.ViewNotFoundException: Unab..."`

I have tried alternate authentication settings, I have tried adding a content type in the change note to indcate the json output, I have also changed the return formatting and nothing seem to make a difference.

Looking for a crumb to follow, have searched till my searcher is sore.

Thanks

Try before your http-request node to set the headers for json (not for Content-type but for Accept)
In a preceding Function node add :

msg.headers = { "Accept" : "application/json"}
return msg;

UnborN - you are a lifesaver, I could not see the forest for the trees on that one. All works now.

Thanks

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.