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

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

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"}

Related

Instagram API graph stories

First I auth my user, which has role instagram Test Users, got access token by doint request to https://api.instagram.com/oauth/access_token Follow Getting Started guide.
Make a request to get user data https://graph.instagram.com/me?fields=username&access_token={{ACCESS_TOKEN}}
Everything OK, got 200 status and data.
Now tried to follow API Stories Docs
make a request to: https://graph.facebook.com/{{IG_ID}}/stories?access_token={{ACCESS_TOKEN}} (IG_ID is the ID I got from user data request) but doesn't work return invalid access token
{
"error": {
"message": "Invalid OAuth access token - Cannot parse access token",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "{ID}" //im not sure if important to hide
}
}
Now tried to use Explorer Api Graph (Tools->Explorer) I generate an access token (this token is generated with Facebook, not instagram), use this token and the ID (/me in Explorer API) in previous request and the response is:
//https://graph.facebook.com/{{ID}}/stories?access_token={{TOKEN}}
{
"error": {
"message": "(#100) Tried accessing nonexisting field (stories) on node type (User)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "{ID}"
}
}
Maybe I'm misunderstanding the guide, anyone have worked with API?
Hmmm... Does API works with private/public accounts? Or only if account is Business/Content Creator might use this?

Intercom API (v2.0) search conversation not working

I tried to search conversation from Intercom API using Postman but it always return server error message.
I just followed their API docs.
request url: POST https://api.intercom.io/conversations/search?query=updated_at>1590278400
The query should be in JSON format in the Body, not in the querystring like you do in your example:
{
"query": {
"field": "updated_at",
"operator": ">",
"value": 1590278400
}
}
In Postman it looks like this (note: don't forget to add your authentication)

Getting "Bad Request" for Postman API

I simply took an example from Postman API Documentation for Create Collection and removed the extra request outside the folder.
My intention is to create just a folder with 1 request in it.
Here is the request:
{
"collection":{
"variables":[
],
"info":{
"name":"Sample Collection",
"description":"This is just a sample collection.",
"schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item":[
{
"name":"This is a folder",
"description":"",
"item":[
{
"name":"Sample POST Request",
"request":{
"url":"echo.getpostman.com/post",
"method":"POST",
"header":[
{
"key":"Content-Type",
"value":"application/json",
"description":""
}
],
"body":{
"mode":"raw",
"raw": "{
\"data\": \"123\"
}"
},
"description":"This is a sample POST Request"
},
"response":[
]
}
]
}
]
}
}
But for this, I am getting "Bad Request" error, what exactly is wrong with my request?
EDIT - Here's what it looks like in Postman
To me, it looks like you’re trying to send the whole collection json file back to that route.
The JSON in the request body on the image is what you would import into Postman to get the Sample Collection folder. This contains a request called Sample POST Request
Copy the request body JSON and save it as a .json file - Then import this using the Import feature in the top left on the application.
This will then create the folder for you in the application with the sample POST request.
If you send it to the echo URL, you will receive a response telling you that the URL has now changed to https://postman-echo.com/post - Add this new URL into the address bar and hit Send.

how to query graph.facebook with postman?

I'm using postman to query from Facebook Graph API. I'm trying next line:
https://graph.facebook.com/v2.8/me?access_token=my_access_token=<here is my user token>
and i get:
{
"error": {
"message": "Invalid OAuth access token.",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "ASBwgp9xF/R"
}
}
I can't figure out alone the right syntax
the access token works at facebook graph api explorer.
You don´t even need postman for this, just hit the URL in your browser.
This is the correct one:
https://graph.facebook.com/v2.8/me?access_token=<here is my user token>

Add Status using Facebook API

I am learning Rest web services using Postman extension of Chrome. I'm practicing it using Facebook API. I have a question about posting in FB.
URI used: https://graph.facebook.com/me/feed?
In the Body of the POST Method, I have given the following Json content
{
"message": "hello",
"access_token": "<a valid token>"
}
I am very sure that my access token is correct as when I append the access token and message with the above URI, the status gets posted successfully. Also when I use it as key-value pairs in 'x-wwww-form-urlencoded' section, it works fine.
But when I try to update the status using the Body of the POST method with the JSON content mentioned above, it tells
{ "error": { "message": "An active access token must be used to query information about the current user.", "type": "OAuthException", "code": 2500 } }
Is there any thing wrong in the format of the JSON content
I missed content-type=application/json
in the Header section.
Adding this solved the problem