Solved

Switching branches with Oauth

  • 13 September 2023
  • 7 replies
  • 86 views

Userlevel 3
Badge

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!

icon

Best answer by kpopova 13 September 2023, 14:20

View original

7 replies

Userlevel 3
Badge +2

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

Userlevel 7
Badge +10

Hi @jamest ,

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

Have you got This link?

Regards,

Sweta

Userlevel 7
Badge +4

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

 

Userlevel 3
Badge

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

Userlevel 3
Badge

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!

Userlevel 3
Badge

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

Userlevel 7
Badge

@jamest - I have corrected the marked answered

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved