connection refused while hitting an api through rest assured in selenium - eclipse

Hi i am using client server, i want to fetch the response from an api which is invoking after clicking a button through selenium code , i create one method to invoke that API, but i got an error connection refused.below is my method :
Response response = RestAssured.get("https://diveui-dive-nonprod.telitcaas1.t-internal.com/case-requirement-service/1.0/caseGroupRequirement/BPFRMHAKEL/0");
CaseRequirement caseRequirement = (CaseRequirement) response.getBody();
System.out.println("Response Body is => " + caseRequirement.getRequirementId());
return String.valueOf(caseRequirement.getRequirementId());
}
can someone help me on this?

Related

Apex Rest callout for Access token

I want to generate a simple post call from Apex for the access token. I am new to Apex and Rest so is there someone explain me how to do that?
I have endpointurl, client _secret, client_id, scope, and grant_type is Client_credentials'.
I tried to run this in Postman and it works fine but not in salesforce.
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://xxx.xxx.eu/o/oauth2/token');
string mybody='{"client_id":"xxxx","client_secret":"xxxx","grant_type":"client_credentials","scope": "xxx.Rest.everything"}';
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody(mybody);
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() != 201) {
System.debug('The status code returned was not expected: ' +
response.getStatusCode() + ' ' + response.getStatus());
} else {
System.debug(response.getBody());
}
ยดยดยดยด
Have you added the remote site? It is the probable reason I believe.
If not, try
From Setup, enter Remote Site Settings in the Quick Find box, then
select Remote Site Settings.
Click New Remote Site.
Enter a descriptive term for the Remote Site Name.
Enter the URL for
the remote site. Optionally, enter a description of the site.
Click Save

Salesforce Integration With facebook messanger

I want to integrate SalesForce with Facebook Messenger. For this I've retrieved access token, app id , app secret. When I hit a HTTP request in developer console to send a message then there is an error.
In the given code it is not accepting messages as parameter throwing error but working without messages.
ref: https://developers.facebook.com/docs/messenger-platform/send-messages/?translation#sending_text
Httprequest req = new httpRequest();
req.setEndPoint('https://graph.facebook.com/v5.0/1798927698340/messages?access_token={PUT-ACCESS-TOKEN-HERE}');
String body = '{'+
'"recipient": {'+
'"id": "100042977199143"'+
'},'+
'"message": {'+
'"text": "hello, world!"' +
'}' +
'}';
req.setMethod('POST');
req.setHeader('Content-Type','application/json');
Http h = new Http();
HttpResponse res = h.send(req);
system.debug(res.getBody());
error message :
16:55:58:127 USER_DEBUG [16]|DEBUG|{"error":{"message":"Unsupported
post request. Object with ID 'me' does not exist, cannot be loaded due
to missing permissions, or does not support this operation. Please
read the Graph API documentation at
https://developers.facebook.com/docs/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"AcqDT5M6mGXSOCr4mOd3kDf"}}
actual response : success = true
This problem arises sometimes when we use invalid access token or user access token instead of page access token.

Unable to get past login page using jsoup

I am unable to get the desired response using jsoup to login and scrape the referred page.
I am trying to access a page called https://localhost/private/frontpage.do , and I can see that the POST method is POST security_check which I gleaned via firebug with the parameters password=guest&username=guest&submit=.
When I use the following code I still am unable to get to the desired page.
Response res = Jsoup
.connect("https://localhost/private/security_check")
.data("j_username", "guest")
.data("j_password", "guest")
.referrer("https://localhost/private/frontpage.do")
.data("submit", "")
.method(Method.POST)
.execute();
Document doc = res.parse();
String sessionId = res.cookie("SESSIONID");
Document doc2 = Jsoup.connect("https://localhost/private/frontpage.do")
.cookie("SESSIONID", sessionId)
.get();
I received the following POST location and parameters from firebug as follows https://localhost/private/j_security_check?password=guest&username=guest&submit=
Any idea why I cant see the new page, but get a HTTP error instead in Java Exception in thread "main" org.jsoup.HttpStatusException: HTTP error fetching URL. Status=408

WSO2 Getting POST PUT DELETE REST parameters

Is there a way to get the parameters set in a post-delete-put REST request? in a proxy or programmatically developing a mediator (i mean in the MessageContext object passed to the mediate method)?
I know that parameters are appended to the url in a GET request e they appear by
getProperty("REST_URL_POSTFIX");
What about the other CRUD commands?
To get programatically, you can retrive those details from Axis2 messagecontext.
HttpServletRequest obj = (HttpServletRequest)
msgContext.getProperty("transport.http.servletRequest");
System.out.println("Method :" + obj.getMethod());
Here is a detail post

gwt: making remote calls fails - sop?

I am writing some interface for users to collect data and send to a server. I went for GWT for various reasons.
Now, when I try to call my server:
String url = "http://127.0.0.1:3000/data/collection.xml";
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));
Request request = builder.sendRequest(data, new RequestCallback() {
public void onResponseReceived(Request request, Response response) {
if (200 == response.getStatusCode()) {
result.setText("SUCCESS!");
} else {
result.setText("ERROR with code: " + response.getStatusCode());
My server gets the request (a POST with some data) but I get ERROR with code: 0 (!) all the time. I guess this has to do with SOP. I read lots about this SOP but I am even more confused now. I tried to follow this tutorial but that's using a different approach (I managed to adapt it to issue GET calls only, but return objects are always null).
Can anyone point me into the right direction? thanks
You can not call any service from another server because of SOP. What you can do, you can use your original server as proxy to other servers.. I would recommend you to read this tutorial.