How to send error details like as BadRequest - grpc

I need send rich structured error details on gRPC error.
I think it's maybe like this:
fv = BadRequest.FieldViolation(field="login", description="Name is not unique")
bad_request = BadRequest(field_violations=[fv])
context.abort(StatusCode.INVALID_ARGUMENT, bad_request.SerializeToString())
But is's wrong and send bytes in summary error text.
I use grpcio==1.17.1

I got feedback on github issue https://github.com/grpc/grpc/issues/17601
Everything works in version 1.18.0

Related

Verification of Payment api of Payu is not working

I am trying to integrate PayU in my website, I have successfully done the payment api part. Now I am trying to call verification api of transaction. I have followed all the steps from documentation.
Method POST:https://test.payu.in/merchant/postservice?form=2
Image
I am getting, Sorry Some Problem Occurred without any proper error message.
I am stuck on this. Please help.
Any help or comment will be highly appreciated.
My code: Function to make string(in expected format given in the documentation) and Hash using SHA256
{ string command = "verify_payment";
string finalStringToBeHashed = PAYU_KEY +"|"+ command + "|" + transactionId + "|" + PAYU_SALT;
string hash = _iPayUServices.GetSHA256(finalStringToBeHashed);
return Ok(( hash, finalStringToBeHashed));
}
and I am confident that my GetSHA256() function is correct. (As it working for payment api's).
Instead of https://test.payu.in/merchant/postservice?form=2 URL,
use https://info.payu.in/merchant/postservice?form=2.
Actually They are upgrading their documentation, so many things are missing as of now. Hopefully, they will add this soon.

No output when pushing from R to slack using slackr

Tried setting up slackr using the following code:
slackr_setup(channel=channel,
incoming_webhook_url="https://hooks.slack.com/services/xxxxxxx/xxxxxx/xxxxxxxxxx",
api_token = "xxxx-xxxxxxxx-xxxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx",
username=username)
However, when I run the slackr function, there is no output. (There's no error message)
Okay,so I found the reason for this. Didn't want to answer my own question, but it might help someone else having the same issue.
The channel that I was trying to post to was a private channel and once I changed the channel to a public one, it started working.

PhantomJs onResourceReceived URL decode issue

I'm creating a web scraping bot in PhantomJs, I'm using onResourceReceived to sniff the the requests of the site and retrieve them using this simple code:
page.onResourceReceived = function(response)
{
if (response.url.match("XXXXXXX"))
{
console.log(response.url);
}
};
My problem is that response.url automatically update the data to a URL-decoded version of this. I need to check some parameters but instead of receiving something like this :
xxx.com?...&events=event20%2Cevent4%%2Cevent89%3D7%2Cevent50%2Cevent51%2Cevent52%2Cevent53%2Cevent54%2Cevent55%2Cevent56&...
I get this
xxx.com?... &events=event20%2Cevent4%2Cevent89%3D7&....
It looks like when %3D is reached it cuts the value and continues to the next property.
Is there a way to access the raw version of this data?
Thanks a lot for the help.

JClouds not able to get the list of images

I have used the code below:
Iterable<Module> modules = ImmutableSet.<Module> of(
new SshjSshClientModule());
ContextBuilder builder = ContextBuilder.newBuilder(provider).endpoint(endpoint)
.credentials(identity, credential)
.modules(modules);
System.out.printf(">> initializing %s%n", builder.getApiMetadata());
ComputeService compute = builder.buildView(ComputeServiceContext.class).getComputeService();
System.out.println(compute1.listImages());
but I am getting the following error message.........
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 787
at org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$DeserializeIntoParameterizedConstructor.read(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:181)
at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.readAndBuild(NullFilteringTypeAdapterFactories.java:92)
The code was working... before...
You've definitely hit a bug somewhere between the version of jclouds you're using and whatever version of whatever cloud you're using. We'll need more information to fix this. Please go through the instruction on how to Report a Bug to Apache jclouds.

trouble with example google maps code

executing this:
$curl "http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false"
returns this:
{
"results" : [],
"status" : "ZERO_RESULTS"
}
Why doesn't it work?
Cheers!
Not sure, but I get the same results when I hit that URL directly in the browser. It may have something to do with that being the sample address that is shown in Geocoding Responses section of the Google Maps API Web Services Dev Guide. Maybe they turned it off because it was getting overloaded?
I even tried a version of that address that has been URL encoded:
http://maps.googleapis.com/maps/api/geocode/json?address=1600%20Amphitheatre%20Parkway%2C%20Mountain%20View%2C%20CA&sensor=false
but get the same result as the original attempt.
I can tell you that if you go directly to http://maps.google.com/maps and key in: 1600 Amphitheatre Parkway, Mountain View, CA, you do get results.
At any rate, your URL is basically formatted correctly and should work. Try a different address, formatted the same way, and you will get results. This worked fine for me:
http://maps.googleapis.com/maps/api/geocode/json?address=Wrigley+Field&sensor=false
Some follow up, I'm not sure where you were trying to run your code, but if it was in a jsFiddle, you may be interested in this question: JQuery won't get json?

Resources