Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Node red http request to ctrlX CORE System API

Node red http request to ctrlX CORE System API

ctrlXnovo
New Contributor

I'm trying to command a GET request to the ctrlX System API, using Node Red.  I'm trying to read the tempCpu variable.

Working: issuing command from localhost, ie: Node Red running on the same CORE where I am directing the GET request.  You can see the flow and the result in the working.png picture and FlowWorking.txt files attached.

Not Working: issuing the same command from a different device, trying to issue the GET request to the other CORE IP address.

For the GET request, I get this error:

"Error: error:0909006C:PEM routines:get_name:no start line : https://192.168.1.10/system/api/v1/sensors/tempCpu"

I tried a variety of different ways of using certificates, keys and tokens to get the command to work, but none have worked.  I used the certificates and keys, in various combinations from the "Web Server" section of certificates and keys on the CORE, of whose temperature I would like to read. 

I looked at the documentation on the REST API that described obtaining the bearer token.  I tried this in YARC and it works fine.  The same POST command from Node Red also returns a similiar error such as this one:

"Error: error:0909006C:PEM routines:get_name:no start line : https://192.168.1.10/identity-manager/api/v1/auth/token"

I have seen Node Red examples elsewhere for data layer, but nothing for the APIs, like the System API.

I'm out of ideas...any advice or code examples of how to do this?

 

3 REPLIES 3

CodeShepherd
Community Moderator
Community Moderator
  1. why don't you use the standard ctrlX contribution nodes available in NodeRed and GitHub?
    CodeShepherd_0-1631170378462.png
    There is also an example how to read the actual CPU utilisation.

  2. You can get a token like you do with the YARC also in NodeRed:
    1. I build up my message:
      var newMsg = {};
      newMsg.header = {};
      newMsg.header["Content-Type"] = "application/json"
      newMsg.payload = 
      {name: boschrexroth, password: boschrexroth}
      newMsg.url = "https://192.168.1.2/identity-manager/api/v1/auth/token";
      return newMsg;​
    2. And then activate SSL/TLS and send a POST:
      CodeShepherd_1-1631170887789.pngCodeShepherd_2-1631170913598.png

       

       

 

To answer your questions:

1. The ctrlX contribution nodes seem to be only for the data layer.  I am trying to use the System API.  I tried this anyway, to be sure, but the reads failed in a couple of different configurations:

ctrlXnovo_0-1631191672884.png

2. I tried your suggestion but I get an error I was also getting before.  I did not mention it, but I had this error when trying to use the certificate settings in the Node Red HTML node: 

ctrlXnovo_1-1631191816907.png

I must admit that I am not very knowledgable (yet) on REST API authentication and when to use certificates, keys, tokens, etc.  This test is my effort to learn about it more.

 

 

I just tested the way described by me again in an new set up ubuntu and everything works fine.

Please send me a private message with your contact data then I can have a look to your application.

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist