Error on creating invoice using APIs from Postman and salesforce - quickbooks

I'm trying to create an invoice record from Postman and Salesforce and from both the places I'm getting error.
To me it looks like a syntax error, but couldn't find it
In Postman Invoice Create, I'm passing below body:
{
"Line": [
{
"Amount": 100.00,
"DetailType": "SalesItemLineDetail",
"SalesItemLineDetail": {
"ItemRef": {
"value": "1",
"name": "Services"
}
}
}
],
"CustomerRef": {
"value": "58"
}
}
But I'm getting this error:
{"Fault":{"Error":[{"Message":"Error parsing
query","Detail":"QueryParserError:
null","code":"4000","element":"Query"}],"type":"ValidationFault"},"time":"2021-05-01T09:07:03.252-07:00"}
In Salesforce I'm using below code to create invoice:
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://sandbox-quickbooks.api.intuit.com/v3/company/462081dsfdsfsfds550/query?minorversion=56');
request.setMethod('POST');
request.setHeader('Accept', 'application/json');
request.setHeader('Content-Type', 'application/text');
request.setHeader('Authorization', authorization);
request.setHeader('Authorization', 'Bearer sessionId');
string body = '{"Line": [{"DetailType": "SalesItemLineDetail","Amount": 100.0,"SalesItemLineDetail": {"ItemRef": {"name": "Services", "value": "1"}}}], "CustomerRef": {"value": "58"}}';
request.setBody(body);
HttpResponse response = http.send(request);
I'm getting below error for this:
{"Fault":{"Error":[{"Message":"Error parsing query","Detail":"QueryParserError: Invalid content. Lexical error at line 1, column 1. Encountered: \"{\" (123), after : \"\"","code":"4000"}],"type":"ValidationFault"},"time":"2021-05-01T09:10:23.563-07:00"}
To me it looks like some syntax error, but not sure where it is

I found the issue, it was because of URL
I was using this:
https://sandbox-quickbooks.api.intuit.com/v3/company/462081dsfdsfsfds550/query?minorversion=56
instead of
https://sandbox-quickbooks.api.intuit.com/v3/company/462081dsfdsfsfds550/invoice?minorversion=56

Related

Hasura query action exception

Got a small problem (I guess). I created c# rest web API on docker swarm environment. Rest API is working properly - tested via the postman. Then I tried to compose Hasura service on the same docker swarm environment. The console is working properly also. The problem is with query action.
Code:
Action definition:
type Query {
getWeatherForecast : [WeatherForecastResonse]
}
New types definition:
type WeatherForecastResonse {
date : String
temperatureC : Int
temperature : Int
summary : String
}
Handler:
http://{api ip}:{api port}/WeatherForecast
While trying to execute query:
query MyQuery {
getWeatherForecast {
temperature
summary
date
temperatureC
}
}
All I got from response is error with json:
{
"errors": [
{
"extensions": {
"internal": {
"error": "invalid json: Error in $: not enough input",
"response": {
"status": 405,
"body": "",
"headers": [
{
"value": "Mon, 14 Jun 2021 13:54:00 GMT",
"name": "Date"
},
{
"value": "Kestrel",
"name": "Server"
},
{
"value": "0",
"name": "Content-Length"
},
{
"value": "GET",
"name": "Allow"
}
]
},
"request": {
"body": {
"session_variables": {
"x-hasura-role": "admin"
},
"input": {},
"action": {
"name": "getWeatherForecast"
}
},
"url": "http://{api ip}:{api port}/WeatherForecast",
"headers": []
}
},
"path": "$",
"code": "unexpected"
},
"message": "not a valid json response from webhook"
}
]
}
I got desired response by using postman white calling: http://{api ip}:{api port}/WeatherForecast (GET method)
Where should I improve, to finally get desired result from rest api?
P.S. hasura version: v2.0.0-alpha.4 (tried also with v1.3.3)
UPDATE:
Released a new version of web API. Inside WeatherForecastController included a new method with POST attribute. Query remained the same, but now graphql query returns what I want.
So the question is: Is it possible to call/access web api methods with GET attribute with Hasura action query?
From the version v2.1.0 and above we can do this using the REST Connectors.Hasura Actions RESTConnectors Methods
Go to the Actions tab on the console and create or modify an action. Scroll down to Configure REST Connectors.
In the Configure REST Connectors section, click on Add Request Options Transform
Along with this you can do a lot of other configurations.
No, currently it's not possible, Hasura always makes POST requests to the action handler:
When the action is executed i.e. when the query or the mutation is called, Hasura makes a POST request to the handler with the action arguments and the session variables.
Source: https://hasura.io/docs/latest/graphql/core/actions/action-handlers.html#http-handler

Schema Extensions : "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'."

I'm currently building an application that requires me to retrieve users from the Graph API depending of a custom property, in that case, extoe82ql2v_test/companyName but so far, the API responded with Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'."
The request to retrieve the extension :
https://graph.microsoft.com/v1.0/schemaExtensions?$filter=id eq 'extoe82ql2v_test'
The result :
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#schemaExtensions",
"value": [
{
"id": "extoe82ql2v_test",
"description": "Extend data for users",
"targetTypes": [
"User"
],
"status": "InDevelopment",
"owner": "d9a847ce-ca03-4779-88d6-c7e4f98297fe",
"properties": [
{
"name": "companyName",
"type": "String"
},
{
"name": "managerMail",
"type": "String"
},
{
"name": "arrivalDate",
"type": "DateTime"
},
{
"name": "expiryDate",
"type": "DateTime"
}
]
}
]
}
The request to retrieve the users depending of extoe82ql2v_test/companyName :
https://graph.microsoft.com/v1.0/users?$select=extoe82ql2v_test,givenName,surname,mail,mobilePhone,department,companyName,accountEnabled&$filter=extoe82ql2v_test/companyName eq 'test'
The result :
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'.",
"innerError": {
"date": "2020-07-24T20:46:51",
"request-id": "639b8131-70dd-4436-b624-88167fe105eb"
}
}
}
The same query with the Microsoft Graph .NET SDK :
var res = await _graphClient.Users.Request()
.Select($"extoe82ql2v_test,givenName,surname,mail,mobilePhone,department,companyName,accountEnabled")
.Filter($"extoe82ql2v_test/companyName eq 'test'").GetAsync()
I don't understand what the issue is as I followed what the official documentation said about filtering custom properties
Any help is greatly appreciated
Edit : Here is how $select without a $filter looks like
Request :
https://graph.microsoft.com/v1.0/users?$select=givenName,surname,mail,mobilePhone,department,companyName,accountEnabled,extoe82ql2v_test
Response :
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(givenName,surname,mail,mobilePhone,department,companyName,accountEnabled,extoe82ql2v_test)",
"value": [
{
"givenName": "Antoine",
"surname": "D",
"mail": "antoine.d#contoso.com",
"mobilePhone": null,
"department": null,
"companyName": null,
"accountEnabled": true,
"extoe82ql2v_test": {
"#odata.type": "#microsoft.graph.ComplexExtensionValue",
"expiryDate": "2020-12-31T00:00:00Z",
"arrivalDate": "2020-07-22T00:00:00Z",
"managerMail": "antoine.d#contoso.com",
"companyName": "test"
}
}
]
}
Edit 2:
I successfully filtered the users with another custom attributes, extoe82ql2v_test/managerMail, it's progress but I still need to apply a filter on extoe82ql2v_test/companyName and make it works
Edit 3:
Filtering on extoe82ql2v_test/expiryDate and extoe82ql2v_test/arrivalDate also works, both of these attributes are useless to filter but at least I know they work. As for extoe82ql2v_test/companyName, I wonder if it is because this attribute exists in both the schema extensions and the User Graph object ?
I just faced the same problem and made it work by adding "$count=true" in the query parameters.
I also noticed it seems to need ConsistencyLevel=eventual in the request header.
For example:
https://graph.microsoft.com/v1.0/users?$filter=CompanyName eq 'xxxx'&$select=id,displayName,CompanyName
Bad Request - 400 - 146ms
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'.",
...
}
https://graph.microsoft.com/v1.0/users?$count=true&$filter=CompanyName eq 'xxxx'&$select=id,displayName,CompanyName (with header ConsistencyLevel=eventual)
OK - 200 - 404ms
\o/
(I got the hint by looking at this question Microsoft Graph API cannot filter /users by companyName?)

Jira API: Add Comment Using Edit Endpoint

Jira has a an /edit endpoint which can be used to add a comment. There is an example in their documentation that suggests this input body to accomplish this:
{
"update": {
"comment": [
{
"add": {
"body": "It is time to finish this task"
}
}
]
}
}
I create the exact same input in my Java code:
private String createEditBody() {
JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
ObjectNode payload = jsonNodeFactory.objectNode();
ObjectNode update = payload.putObject("update");
ArrayNode comments = update.putArray("comment");
ObjectNode add = comments.addObject();
ObjectNode commentBody = add.putObject("add");
commentBody.put("body", "this is a test");
return payload.toString();
}
but when I send this PUT request I get an error saying that the "Operation value must be of type Atlassian Document Format"!
Checking the ADF format it says that "version", "type" and "content" are required for this format. So although their documentation example doesn't seem to be ADF format, I'm trying to guess the format and change it. Here's what I accomplished after modifying my code:
{
"update": {
"comment": [
{
"add": {
"version": 1,
"type": "paragraph",
"content": [
{
"body": "this is a test"
}
]
}
}
]
}
}
the add operation seems to be an ADF but now I get 500 (internal server error). Can you help me find the issue?
Note that the above example from Atlassian documentation is for "Jira Server Platform" but the instance I'm working with is "Jira Cloud Platform" although I think the behaviour should be the same for this endpoint.
after tinkering with the input body, I was able to form the right request body! This will work:
{
"update": {
"comment": [
{
"add": {
"body": {
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "this is a test"
}
]
}
]
}
}
}
]
}
}
The annoying things that I learned along the way:
Jira's documentation is WRONG!! Sending the request in their example will fail!!
after making a few changes, I was able to get 204 from the endpoint while still comment was not being posted! And I guessed that the format is not correct and kept digging! But don't know why Jira returns 204 when it fails!!!

JIRA API after POST returns { errorMessages: [ 'Internal server error' ], errors: {} }

I am trying to create a new issue utilizing the JIRA REST API and whenever I try, I get back the following generic error:
{ errorMessages: [ 'Internal server error' ], errors: {} }
I can successfully GET from the API, and the credentials I'm connecting with have full Admin access to JIRA (so it's not an Auth issue), but I get this error every time with POST. Below is a snippet of the JSON data I'm sending. Am I missing anything obvious?
Below is my JavaScript code. Note I'm using jira-connector from npm. (Real domain replaced with mydomain for this sample code)
const JiraClient = require('jira-connector');
const dotenv = require('dotenv').config();
function createNewIssue(fields) {
const encoded = process.env.JIRA_ENCODED_PW;
const jira = new JiraClient({
host: 'mydomain.atlassian.net',
basic_auth: {
base64: encoded
}
});
return new Promise((resolve, reject) => {
jira.issue.createIssue(fields, (error, issue) => {
if (error) {
console.log(error);
reject(error);
} else {
console.log(issue);
resolve(encoded);
}
});
})
}
Below is the JSON that's being passed into fields in the JS above. Note customfield_17300 is a radio button, and customfield_17300 is a multi-select box. For both cases, I've tried using the "id" and also the actual string "name" value. All IDs below were taken straight from a API GET of the same issue in question:
{
"fields": {
"project": {
"id": "13400"
},
"summary": "TEST API TICKET - 01",
"issuetype": {
"id": "11701"
},
"customfield_14804": { "id": "13716" },
"customfield_14607": "Hardware",
"customfield_17300": [
{
"id": "18322"
}
] ,
"customfield_16301": "Customer PO",
"customfield_14800": "LA, California",
"customfield_16302": "FEDEX 234982347g"
}
}
sigh I figured it out... other posts that said this cryptic error was due to a malformed JSON were correct.
In my route, I passed fields as coming from req.body.fields which actually dove into the fields values instead of passing it straight through. This made it so that when the JSON was sent to JIRA the fields outer wrapper was missing. I changed my route to pass along req.body instead of req.body.fields and all was well.
...that was a fun 4 hours...

Rest-Assured Get jsonPath when JSON key starts with number

How do i get name=status using json path ... problem here is key=2 is random number,,, is their any way to skip these random and read name
Am using rest assured ,,this is sample response on GET request
Response
{
"error": false,
"message": "",
"data": {
"2": {
"name": "No Status",
"protected": "1",
"id": "1",
"temporal_start": "0",
"temporal_end": "2147483647"
},
"3": {
"name": "Started",
"protected": "1",
"id": "2",
"temporal_start": "0",
"temporal_end": "2147483647"
},
}
}
my request code is
given()
.param("error", "false")
.when()
.get(URI)
.then()
.body("data.2.name", startsWith(No))
I've found a solution but it's not very elegant:
when().
get(URI).
then().
body("data.collect { it.value }.reverse()[0].name", equalTo("No Status")).
body("data.collect { it.value }.reverse()[1].name", equalTo("Status"));
Which can be simplified using root paths:
when().
get(URI).
then().
root("data.collect { it.value }.reverse()[%d].name").
body(withArgs("0"), equalTo("No Status")).
body(withArgs("1"), equalTo("Status"));
Explanation:
Since data is a JsonObject represented as a HashMap we run the collect method to return only the values of the Map as a List. Then we reverse the list since it seems like the last when running collect the resulting list will have the last value first. Then we get the first value from this list (data.2 in your example) and finally get the name.

Resources