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

How to send bearer token in JSON

AndroidzZ
Established Member

How to send bearer token in JSON

i'm kinda new to JSON. i already checked: https://developer.community.boschrexroth.com/t5/ctrlX-AUTOMATION-Community/Using-REST-API-of-ctrlX-C... but here is not what I am looking for.

I have a database that needs to send a variable to the CORE every time something is scanned. The database can send this information to the CORE in JSON code.

In postman I get it working because there is a specific box there to send the bearer token with. I assume the bearer token should be sent along with every request in the header.
How can I send the bearer token with every PUT request? I am looking for the specific piece of code which allows me to send an bearer token to the CORE every time i make a request. 

 

Tags (4)
11 REPLIES 11
CodeShepherd
Community Moderator

Re: How to send bearer token in JSON

I am not sure how your database (which one is it?) sends it requests and which programming language is used but in an standard https request just add the "Authorization" including the bearer token to your header e.g. like you can see in the topic you mentioned with YARC as an example client:

CodeShepherd_0-1623749685979.png

 

AndroidzZ
Established Member

Re: How to send bearer token in JSON

what does that look like if I wanted to send that in for example from Visual Studio. the tutorial says I should send it in a "request header".

the database i mentioned is our own database. the database communicates in JSON among other things.

A piece of code needs to be created that updates a variable each time. Only the piece of code to send the Bearer token with each request is not working for me.

Could the code look like this after logging in ? :

{
    "access_token""XXX",
    "token_type""Bearer"
}

{
"type": "int32",
"value": 10000
}

CodeShepherd
Community Moderator

Re: How to send bearer token in JSON

The bearer token must not be part of the payload of the request but part of the header of an https request.

This is how it works in NodeJs.

 

var newMsg = {};
newMsg.headers = {};
newMsg.headers['authorization'] = global.get("authorization");

newMsg.payload = 
{"type":"bool8", "value": msg.payload};
newMsg.url = "https://" + global.get("IP") + "/automation/api/v1.0/plc/app/Application/sym/GVL/start";
return newMsg;

 

So I cannot tell how it looks like for your database without more information about it. Please contact me directly with some contact data of your side so we could have a call/meeting.

AndroidzZ
Established Member

Re: How to send bearer token in JSON

Thanks for the offer! ill come back at you for a possible meeting. We will try a couple of things ourself first.

CodeShepherd
Community Moderator

Re: How to send bearer token in JSON

Any news from your side?

AndroidzZ
Established Member

Re: How to send bearer token in JSON

Last 1.5 weeks I had vacation so there have not been many follow-up steps. I will give an update soon.

AndroidzZ
Established Member

Re: How to send bearer token in JSON

upcoming week there will be some tests. If we are not successful after next week, I will gladly take up the offer to schedule a meeting/call.

TheCodeCaptain
Community Moderator

Re: How to send bearer token in JSON

Hi AndroidzZ,

did you figure out how to set the bearer header for the REST client you are using?

Would you share your result?

Regards

AndroidzZ
Established Member

Re: How to send bearer token in JSON

No improvements yet. We would like to schedule a meeting/call for some help if possible 

davidOtis
Occasional Visitor

Re: How to send bearer token in JSON

@AndroidzZ

Thank, I also have the same problem

CodeShepherd
Community Moderator

Re: How to send bearer token in JSON

Sorry for the delay. I will get in contact with you directly.

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