How to pass request in valid format for create multiple entry in workflowGenJournalLines on business central by Odata V4 URL - dynamics-business-central

When I pass into array of object format than give error
"error": {
"code": "BadRequest",
"message": "Invalid Request Body CorrelationId: 43f92900-efcb-4616-9a41-2892346f9dd0."
}
How to pass request in valid format for workflowGenJournalLines in business central

Related

Linkedin API - Group Memberships - "Invalid query parameters passed to request"

I'm trying to get my groups where I owner, so I'm trying to perform a GET request on
GET
https://api.linkedin.com/v2/groupMemberships?q=member&member={person URN}&membershipStatuses=List(MEMBER,OWNER)
But I'm getting the following error:
{
"serviceErrorCode": 0,
"message": "Invalid query parameters passed to request",
"status": 400
}
My request to "Marketing Developer Platform" was approved and I am putting the headers in the request:
X-Restli-Protocol-Version: 2.0.0
Authorization: Bearer {{accessToken}}
In the parameter
member={person URN}
I am sending.
member=urn:li:person:{{accountId}}
What am I doing wrong?

Google calendar push notification, login required error

I am following the docs https://developers.google.com/calendar/v3/push#creating-notification-channels
I am trying to setup my channel to watch for changes to events, using postman I am posting to:
https://www.googleapis.com/calendar/v3/calendars/xxx/events/watch
[{"key":"id","value":"xxx#xxx.co.uk"},
{"key":"type","value":"web_hook"},
{"key":"address","value":"https://xxx.firebaseapp.com"},{"key":"key","value":"AIzaSyBkAEZGoQwB0f-Kmq4mCCzm93422up8oQw"}]
I keep getting the error below:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Any ideas why I am getting this? I can fetch data from the API ok.
You are getting the 401 "login required", it means that you are using an expired or invalid access.
Check this Google group discussion on how the process was done on getting the refresh token using the client ID and client secret to implement the authenticated and authorized API calls.
See also references:
Google calendar API returns error 401 'login required' on inserting event in public calendar
Error with Google Calendar API - 401 Login required when adding a calendar event
Using API Key to authenticate a request generates a 401 error

HTTP status codes when errors in the request body

Can someone please clarify what status codes should I expect from following situations? For instance, I am sending POST request with such body format:
{
"id": 321,
"username": "tombrown",
"email": "tombrown#gmail.com",
"password": "qwerty123",
"activated": true
}
So the questions are:
1) Should the server return 400 if I specify data of wrong type, for instance, "id": “threetwoone” instead of int, "activated": “yes” instead of boolean etc. Or server should rather return 422 here?
2) The “id” value should be int, but actually it is long int, e.g. 9223372036854774700.
3) Some fields are missing in the body, e.g. I try to send:
{
"id": 321,
"username": "tombrown",
"activated": true
}
Should these examples cause 400, 422 or some other options? What reaction should be correct?
If the JSON is syntactically invalid, return 400. If JSON is syntactically valid but its content is invalid, return 422 to indicate that the request entity cannot be processed by the server.
See the following quote from the RFC 4918 (for your situation, just read JSON when it says XML):
11.2. 422 Unprocessable Entity
The 422 (Unprocessable Entity) status code means the server
understands the content type of the request entity (hence a
415 (Unsupported Media Type) status code is inappropriate), and the
syntax of the request entity is correct (thus a 400 (Bad Request)
status code is inappropriate) but was unable to process the contained
instructions. For example, this error condition may occur if an XML
request body contains well-formed (i.e., syntactically correct), but
semantically erroneous, XML instructions.

unable to access json data using RequestsLibrary of robotframework : TypeError: expected string or buffer

in below three test cases Get Requests1, Get Requests2 and Get Requests3. I tried to get /RestResponse/result node value by three different way but it show same error
*** Settings ***
Library Collections
Library OperatingSystem
Library HttpLibrary.HTTP
Library RequestsLibrary
*** Test Cases ***
Get Requests1
# create a HTTP session to a server
Create Session countryname http://services.groupkt.com
# store response
${resp}= Get Request countryname /country/get/all
log ${resp.content}
# ${resp.content} display entire json response, now tring to get node value of /RestResponse/result
${getResponseJson} Get Json Value ${resp} /RestResponse/result
# shows error TypeError: expected string or buffer
log ${getResponseJson.content}
Get Requests2
# create a HTTP session to a server
Create Session countryname http://services.groupkt.com
# store response
${resp}= Get Request countryname /country/get/all
log ${resp.content}
# ${resp.content} display entire json response, now tring to get node value of /RestResponse/result
${responseContent}= to json ${resp.content}
# shows error TypeError: expected string or buffer
${getResponseJson} Get Json Value ${responseContent} /RestResponse/result
log ${getResponseJson.content}
Get Requests3
# create a HTTP session to a server
Create Session countryname http://services.groupkt.com
# store response
${resp}= Get Request countryname /country/get/all
log ${resp.content}
# ${resp.content} display entire json response,parse json
${data} Parse Json ${resp}
# shows error TypeError: expected string or buffer
${getResponseJson} Get Json Value ${resp} /RestResponse/result
Json file response
{
"RestResponse": {
"messages": [
"Total [249] records found."
],
"result": [
{
"name": "Afghanistan",
"alpha2_code": "AF",
"alpha3_code": "AFG"
},
{
"name": "\ufffd\ufffdland Islands",
"alpha2_code": "AX",
"alpha3_code": "ALA"
},
{
"name": "Albania",
"alpha2_code": "AL",
"alpha3_code": "ALB"
},
{
"name": "Algeria",
"alpha2_code": "DZ",
"alpha3_code": "DZA"
}
]
}
}
You need to call Get Json Value from the JSON, not from the request object. In your code, ${resp} is an object that includes the JSON data plus other things that json parsers don't know about.
${getResponseJson} Get Json Value ${resp.content} /RestResponse/result
${resp} is a python object. It has the json data, but it also has the HTTP return code and other information. You can't pass it to anything that accepts JSON.
${resp.content} is the body of the HTTP response. Like you write in your comments, this is the JSON data. Any keyword that accepts JSON data should accept this.
${resp.json} is the JSON string of the response converted to a python object. It is no longer JSON, it's a python dictionary. You cannot pass this to any function that requires JSON. You can, however, treat it like a normal python dictionary.
After running the code, ${getResponseJson} will have the data you expect. It is a unicode string, and unicode strings don't have a content attribute.

google-bigquery how to get datasetlist with https get?

I'm trying to get dataset list from bigquery webserver with https get
following the documentation here:
https://developers.google.com/bigquery/docs/reference/v2/datasets/list
i'm using slightly modified code from:
http://code.google.com/p/qt-google-bigquery/source/browse/manager_bigquery.cpp
getDatasetsList(QString strProjectID)
{
QString url = QString("https://www.googleapis.com/bigquery/v2/projects/%1/datasets?key=%2").arg(str_ProjectID).arg(this->api_key);
//Also tried without ?key= part
QNetworkRequest request;
request.setUrl( QUrl(url) ); //this also urlencodes
request.setRawHeader("Content-Type", "application/json");
request.setRawHeader("Authorization", (QString("Bearer %1").arg(m_Access_Token)).toLatin1());
//here i post the request as a http get asynchronously
}
i get back this error message:
Reply = "{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter is missing"
}
],
"code": 400,
"message": "Required parameter is missing"
}
}
Note:
I managed to run a query and get the results, so my access token seems to be valid, what am i doing wrong here?
SOLVED
Ah, actually the problem was in my coding, not the request, i posted it as a http post, not a get.
See answer in comment by original poster above - but basically make sure you are using GET instead of the POST method for an API call to list datasets. Other BigQuery API methods use POST, PUT, or PATCH.
https://developers.google.com/bigquery/docs/reference/v2/datasets/list

Resources