I am trying to capture the graphql response from the network response tab using the selenium4 dev tool.
I have tried the below code and its prints all data from the 30 + requests available on the network response but I just want to fetch graphql file and print the response available with graphql request.
DevTools finalDevTools = devTools;
devTools.addListener(Network.responseReceived(), responseReceived -> {
requestIds[0] = responseReceived.getRequestId();
String url = responseReceived.getResponse().getUrl();
int status = responseReceived.getResponse().getStatus();
String type = responseReceived.getType().toJson();
String headers = responseReceived.getResponse().getHeaders().toString();
String responseBody = finalDevTools.send(Network.getResponseBody(requestIds[0])).getBody();
System.out.println(responseBody);
});
Related
Referring to the Documentation on Google Cloud Java, trying to access features using FeaturestoreOnlineServingServiceClient Service as per the document.
Relevant bits of code
try (FeaturestoreOnlineServingServiceClient featurestoreOnlineServingServiceClient =
FeaturestoreOnlineServingServiceClient.create()) {
String gcpProject = this.featureStoreConfig.getProject();
String featureStoreName = this.featureStoreConfig.getFeatureStoreName();
String featureStoreLocation = this.featureStoreConfig.getLocation();
EntityTypeName entityTypeName =
EntityTypeName.of(gcpProject, featureStoreLocation, featureStoreName, entityType);
System.out.println(entityTypeName);
ReadFeatureValuesResponse response =
featurestoreOnlineServingServiceClient.readFeatureValues(entityTypeName);
The code crashes on readFeatureValues
Relevant bits of Error
Failed to complete request: com.google.api.gax.rpc.UnimplementedException: io.grpc.StatusRuntimeException: UNIMPLEMENTED: HTTP status code 404
invalid content-type: text/html; charset=UTF-8
<html>
...
<title>Error 404 (Not Found)!!1</title>
...
<p>The requested URL <code>/google.cloud.aiplatform.v1.FeaturestoreOnlineServingService/ReadFeatureValues</code> was not found on this server. <ins>That’s all we know.</ins>
Any suggestions on what could be the error?
I would double check if the Feature Store is available in your region
I got the same error and the problem is around the region. The region needs to be chosen when making the connection in addition to selecting it when making the entity. Try this if your vertex featurestore is not in us-central1
String endpoint = String.format("%s-aiplatform.googleapis.com:443", this.featureStoreConfig.getLocation());
FeaturestoreOnlineServingServiceSettings settings = FeaturestoreOnlineServingServiceSettings.newBuilder()
.setEndpoint(endpoint)
.build();
FeaturestoreOnlineServingServiceClient featurestoreOnlineServingServiceClient =
FeaturestoreOnlineServingServiceClient.create(settings);
String gcpProject = this.featureStoreConfig.getProject();
String featureStoreName = this.featureStoreConfig.getFeatureStoreName();
String featureStoreLocation = this.featureStoreConfig.getLocation();
EntityTypeName entityTypeName = EntityTypeName.of(gcpProject, featureStoreLocation, featureStoreName, entityType);
System.out.println(entityTypeName);
ReadFeatureValuesResponse response = featurestoreOnlineServingServiceClient.readFeatureValues(entityTypeName);
I'm trying to connect to the transmission rpc interface via C#/Java to get some informations back.
https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt
Unfortunatly I have problems to get the correct HTTP-Post to access the interface.
For example if I try this in C#:
using (var client = new WebClient())
{
var values = new NameValueCollection();
values["torrent-get"] = "id";
var response = client.UploadValues("http://ip:9091/transmission/rpc", values);
var responseString = Encoding.Default.GetString(response);
Console.WriteLine("" + responseString);
}
Or if i use:
using (var webClient = new WebClient())
{
String json = "{\"arguments\": {\"fields\": [ \"id\", \"name\", \"totalSize\" ],\"ids\": [ 7, 10 ]},\"method\": \"torrent-get\",\"tag\": 39693}";
var response = webClient.UploadString("http://192.168.240.171:9091/transmission/rpc", "POST", json);
Console.WriteLine(""+response);
}
I get the following error:
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: The Remoteserver returned an exception: (409) conflict.
You must save the X-Transmission-Session-Id provided in the 409 response and resubmit the request with a X-Transmission-Session-Id property added to your request header.
Example in java :
int index = responseString.indexOf("X-Transmission-Session-Id:");
String sessionId = responseString.substring(index + 27, index + 75);
connection.setRequestProperty("X-Transmission-Session-Id", sessionId);
I'm using the SoapUI API as part of an existing java project.
The application should save the request and response XML in an specific report file.
I wonder if it's possible to get those requests and responses via the API.
The method invoking the TestCaseRunner looks like this
protected void checkTestCase(TestCase testCase) {
TestCaseRunner tr = testCase.run(null, false);
for (TestStepResult tcr : tr.getResults()) {
String status = tcr.getStatus();
String time = tcr.getTimeTaken() + "ms";
/* How to get XML messages?
* String request =
* String response =
*/
}
}
Depending on exactly what kind of test steps you have they might be an instance of a MessageExchange. Casting the TestStepResult to a MessageExchange and calling getRequestContent / getResponseContent might do the trick.
String request = ((MessageExchange)tcr).getRequestContent();
String response = ((MessageExchange)tcr).getResponseContent();
I have used the following way to get the response from the API CAll performed:
runner = testRunner.runTestStepByName("Your Test Case name");
// Here we take the response in ms of the API call
timeTaken = runner.response.timeTaken;
// here we get the HTTP response code.
responseCode = runner.getResponseHeaders()."#status#";
// here we get the response content
String response = runner.getResponseContent();
// here we get the API call endpoint -> in case you need to print it out.
String endPoint = runner.getEndpoint();
i need to connect to a rest service to get the user id by using a token.
List<Object> providers = new ArrayList<>();
providers.add(new JacksonJaxbJsonProvider());
client = WebClient.create(properties.getProperty(URL), providers);
client = client.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE);
client.path(PATH + token);
Response response = client.get();
The entity of response have this format:
{"message":"Token is valid","userId":1}
To get the userId, i have:
response.readEntity(AuthResponse.class).userId;
It is possible to take only the userId without creating an class with that format ? (without AuthResponse.class)
You can try to read your JSON as Map, for example: response.readEntity(Map.class).get("userId")
Please refer to this page for more information.
I want to send the data to person object. How to do it with PostMethod.
def payload ='<person><nationalId>'+1234567+'</nationalId></person>'
def method = new PostMethod(url)
def client = new HttpClient()
payload = payload.trim()
method.addRequestHeader("Content-Type","text/xml")
method.addRequestHeader("Accept","text/xml,application/xml;q=0.9")
Credentials credentials = new UsernamePasswordCredentials('simple', 'simple');
client.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST,8080, AuthScope.ANY_REALM, "digest"),credentials);
method.setRequestEntity(new StringRequestEntity(payload))
def statusCode = client.executeMethod(method)
println "STATUS CODE : ${statusCode}"
def resultsString = method.getResponseBodyAsString()
method.releaseConnection()
println resultsString
I tried above coding. How to set password and username and password digest also. For that i think status code 400 is coming.Please notify where i made mistake
Try to look at REST Client Builder Plugin. See docs and I guess, you'll find more convenient way to send request