Splunk REST API error handling with ouput_mode=json OR output_mode=csv - api

Using the Splunk REST API, i see that XML response will return search syntax errors or warnings.
if you select output_mode="csv" or output_mode="json" and the search had a syntax error, it simply finishes quickly and returns zero results.
Is there a way to change this behavior so that an error in syntax will return an error message instead of just sending back 0 results? I'd like to use JSON and not have to overhaul to support XML.
Searching API documents, I keep coming up empty.

Related

HealthCheckUI (AspNetCore.Diagnostics.HealthChecks) Unexpected Character 'H' error

I'm having an issue with the AspNetCore HealthCheckUI.
I followed this example:
https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks#healthcheckui
My UI is up and running and my services are up and running with a healthcheck that just returns a string "Healthy". And I think that's the root cause of the issue.
It looks like the UI is showing a "false" error because it's expecting JSON and seeing a string. And so it's throwing an "Unexpected character 'H'" error while parsing the response.
Is there a way to stop the healthcheckui from expecting json?
Is there a way have this AspNetCore HealthChecksUI package work with a Healthcheck that doesn't return JSON?
Found the closest thing I could find to an answer, which is basically change all my healthchecks to json :(
https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/440

Youtube LiveChat API: messageTextInvalid

I'm using the Youtube livechat.insert API (https://developers.google.com/youtube/v3/live/docs/liveChatMessages/insert), and occasionally get back the messageTextInvalid error. However the error description page doesn't give much of a hint as to what's wrong here (https://developers.google.com/youtube/v3/live/docs/errors#liveChatMessages_youtube.liveChatMessages.insert). I've ensured the messages being sent are <= 200 characters long, and do not have newlines in them. However a message like '(Discord) person: COMMENT : Wonderful!' returns this error that the text is invalid. Is there some information that I can find about what text is valid in the message? I also didn't find much information on the livechat message resource page (https://developers.google.com/youtube/v3/live/docs/liveChatMessages#resource)

How to return both data field and errors field with Graphql-kotlin query

I am working on one server that resolve GraphQL queries. I used the graphql-kotlin library: https://github.com/ExpediaDotCom/graphql-kotlin.
I defined three resolve functions(could be viewed as three fields): getxxx(arguments...), getTarget(arguments...) and getSource(arguments...).
The problem is if one of my queried field failed, I will only get the 'errors' field. All other successful executed results(data) are dropped.
If I try to catch the exception for the failed field, then I will not get the 'error' field at last.
This is the image that had exception and dropped all fetched data:
The objective is returning both the successful fetched data in 'data' field and error message for failed field in 'errors' field.
I have checked this: How to return both error and data in a graphql resolver?
If I set a field that throw one error or exception intentionally, I will only get 'errors' field at last(Like the picture above).
In addition, many websites like this:https://itnext.io/the-definitive-guide-to-handling-graphql-errors-e0c58b52b5e1 suggest we should return partial result and error message, but in my case if I meet exception, only error message would be returned.
In our example application we have two top level queries
{
onlyCake(msg: "cake")
generateNumber
}
If I run this code this will return a random number and onlyCake returns the string <3. However if I modify the input of onlyCake to something that is not the string cake I will get an error. This is expected because the field onlyCake has a directive to implement this behavior.
https://github.com/ExpediaDotCom/graphql-kotlin/blob/2961b64d6e4cceb4034aec198d667e5f965decd2/example/src/main/kotlin/com/expedia/graphql/sample/directives/CakeOnlyDirectiveWiring.kt#L18-L19
The question is though, if I want to return the data still for generateNumber can I do that and have both errors and data in the response?
The answer is it's possible but not with the current schema. The issue is that our schema for onlyCake and generateNumber are both non-nullable fields. So as a client if I see that there is a data field I should expect to see both there otherwise I would have a parsing issue in my code. This is why we can't have this behaviour with the schema as is. If you want to implement this behaviour, the schema developer needs to decide where they can return null for some response and modify the errors field appropriately with a DataFetcherExceptionHandler
Or the other option is that we support the behaviour in graphql-java to return a DataFetcherResult<T> instead of just T from the kotlin functions. See the section Returning data and errors here: https://www.graphql-java.com/documentation/v13/execution/
I have created an issue to continue this discussion with other team members: https://github.com/ExpediaDotCom/graphql-kotlin/issues/244

JMeter variable in GET request failing

I have a GET Request that is returning an XML that contains a TicketName. I have setup the Regular Expression Extractor with Debug Sampler. It is picking up the TicketName as required and is displaying it in the View Results Tree, with the correct name variable name ticketID_g1.
However when I pass that variable to the next GET request the test plan fails with Non HTTP response message: Socket closed.
The thing is that the GET request looks find when I look at the request tab in the Results Tree.
I have changed my regular expression a number of times with each one extracting the TicketName properly but each time I apply it as a variable the GET request fails. However if I copy the request showing in the Results Tree Request Tab and paste it directly into my browser I get the desired result.
I have been through the manuals and on-line tutorials and it appears that I am doing everything right but obviously I am missing something.
The 1st GET Request returns an XML that contains name="2019-05-09-16-59-54cmrpip000613_EDASERVE" needsPrompt
I am using the following regular expression to extract the name for my variable ticketID
name="([^"]+)" needsPrompt - This works
The Results Tree is showing the following response from the Debug Sampler -
ticketID_g1=2019-05-09-16-59-54cmrpip000613_EDASERVE
When I pass the ticketID variable to the next GET request
//localhost:8080/ibi_apps/rs?IBIRS_action=getReport&IBIRS_ticketName=${ticketID_g1}cmrpip000589_EDASERVE&IBIRS_service=defer
The Response tab in the Results Tree for the second GET request is showing that the request is good but is failing.
GET http://localhost:8080/ibi_apps/rs?IBIRS_action=getReport&IBIRS_ticketName=2019-05-09-16-59-54cmrpip000613_EDASERVE&IBIRS_service=defer
What I am expecting is that this second GET will run with the variable and return a report but is throwing the Non HTTP response message: Socket closed error.
You have below variable which is capturing ticket id.
ticketID_g1=2019-05-09-16-59-54cmrpip000613_EDASERVE
But, in the below request you are passing the same which also have repeated content that is
"cmrpip000589_EDASERVE"
Request:-//localhost:8080/ibi_apps/rs?IBIRS_action=getReport&IBIRS_ticketName=${ticketID_g1}cmrpip000589_EDASERVE&IBIRS_service=defer
Please pass the ticketID variable correctly and hopefully it solves the issue. If I am correct you request should look like:-
Request:-//localhost:8080/ibi_apps/rs?IBIRS_action=getReport&IBIRS_ticketName=${ticketID_g1}&IBIRS_service=defer

SQL LIKE '%...' in vba HTTP request

I am trying to run an SOQL query to the Salesforce REST API within a macro in Excel. I am using a LIKE statement to check if there are any email addresses with the same domain, which looks like this:
q=SELECT+email+FROM+Contact+WHERE+email+LIKE+'%#domain.com'
This is just the parameter given to the HTTP request, domain being a placeholder.
When I run the exact same request using Postman I get the correct response from the server, however in Excel I get Error 400 bad request.
When dropping the % it accepts the request, however then it obviously doesn't find any entries, as it is looking for the exact string "#domain.com".
Are there any known problems with the %-sign within vba? Or any other suggestions what could be the problem?
The problem is not with VBA, it is with your HTTP query. You need to escape the percent sign (%), which is a special characters. I guess Postman is doing this for you under the hood.
Hence, try :
q=SELECT+email+FROM+Contact+WHERE+email+LIKE+'%25#domain.com'
See : https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_the_percent_character
If that's not enough for the query to succeed, you may as well escape the arobas sign (#):
q=SELECT+email+FROM+Contact+WHERE+email+LIKE+'%25%40domain.com'