service-layersapb1

SAP B1 Service Layer Login POST request gives error code -304 with an empty message


I'm trying to reach SAP Business One Service Layer APU via PostMan and Python (with requests module). However, when I try to POST to /Login endpoint to our Service Layer it gives me the following JSON result:

{ "error": { "code": -304, "message": { "lang": "en-us", "value": "" } } }

As you can see, it's an error code -304 with an empty message value.

The payload I'm sending is a text like this:

{"UserName":"my_username","Password":"my_password","CompanyDB":"NAME_OF_MY_DB"}

I have tried this payload as well to /Login enpoint but with no successful result:

{"Username":"my_username","Password":"my_password","CompanyDB":"NAME_OF_MY_DB"}

but this results in this JSON result:

{ "error": { "code": 102, "message": { "lang": "en-us", "value": "Invalid login credential." } } }

Can anyone, please, suggest what may be wrong here? I need to Login and then GET the Items from the DB.

Thank you in advance


Solution

  • The issue was that I needed to use a domain before the username. So, at the end, the working payload looks like this:

    {"UserName":"my_domain\\my_username","Password":"my_password","CompanyDB":"NAME_OF_MY_DB"}