Skip to main content
Solved

Switching branches with Oauth

  • Sep 13, 2023 11:42 AM UTC
  • 7 replies
  • 352 views
  • Translate All

jamest
Varsity I
Forum|alt.badge.img

Hi all, 

Is there a way to switch branches for the account used for Oauth? Our vendors are set up with Restricted company groups. When our api automation tries to create a Bill the user used in the Oauth authentication, it is set to one of our 10 branches, so the Bill PUT fails due to the branch being incorrect. During the automation we'll need to switch branches. 

I looked for a profile endpoint to maybe use and switch branches using the api, but didn't see one. Thoughts?

Thanks!

Best answer by kpopova

Please refer to this topic: https://help.acumatica.com/(W(114))/Help?ScreenId=ShowWiki&pageid=9821cff9-4970-4153-a0f8-dbf5758133a7

View original

7 replies

kpopova
Acumatica Employee
Forum|alt.badge.img+3
  • Acumatica Employee
  • Answer
  • Sep 13, 2023 12:20 PM UTC

Forum|alt.badge.img+9
  • Semi-Pro III
  • Sep 13, 2023 12:24 PM UTC

Hi @jamest ,

As far I know, For the branch, we don't have any parameters or conditions.

Have you got This link?

Regards,

Sweta

Translate

RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+5
  • Acumatica Moderator
  • Sep 13, 2023 1:18 PM UTC

this is correct. 

The idea is that you should not really set Branch for a session when you use OAuth. You should provide the branch in the request header with each request. 
The header is 
PX-CbApiBranch

See details here: https://help.acumatica.com/(W(1))/Help?ScreenId=ShowWiki&pageid=9821cff9-4970-4153-a0f8-dbf5758133a7

During my testing locally, I was able to use this header to change branch(review Cookie UserBranch value). 
I made a token call(return cookie UserBranch 16)
Next made a get call and set PX-BcApiBranch header to Products Retail > cookie value for UserBranch changes to 20

 

Translate

jamest
Varsity I
Forum|alt.badge.img
  • Author
  • Varsity I
  • Sep 13, 2023 1:40 PM UTC

This was exactly what I need and it worked! Thanks! I even looked at this help tutorial and I just missed it. 

Translate

jamest
Varsity I
Forum|alt.badge.img
  • Author
  • Varsity I
  • Sep 13, 2023 1:41 PM UTC

this is correct. 

The idea is that you should not really set Branch for a session when you use OAuth. You should provide the branch in the request header with each request. 
The header is 
PX-CbApiBranch

See details here: https://help.acumatica.com/(W(1))/Help?ScreenId=ShowWiki&pageid=9821cff9-4970-4153-a0f8-dbf5758133a7

During my testing locally, I was able to use this header to change branch(review Cookie UserBranch value). 
I made a token call(return cookie UserBranch 16)
Next made a get call and set PX-BcApiBranch header to Products Retail > cookie value for UserBranch changes to 20

 

Yep, this worked!

 

Thanks!

Translate

jamest
Varsity I
Forum|alt.badge.img
  • Author
  • Varsity I
  • Sep 13, 2023 1:42 PM UTC

Sorry, I marked the wrong “right” answer for my situation. @RohitRattan88  and @kpopova answers worked for me. 

Translate

Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • Sep 13, 2023 6:36 PM UTC

@jamest - I have corrected the marked answered

Translate