I am trying to create new test page from REST api calls in Fitnesse. The page is being created but the contents is not being added.
I am using addChild responder.
here is my code.
DefaultHttpClient client = new DefaultHttpClient();
HttpGet post = new HttpGet("http://localhost:80/TestSuite?responder=addChild&pageName=RestSuite&pageType=Suite&content=valuetosave");
HttpResponse response = client.execute(post);
String str1 = EntityUtils.toString(response.getEntity());
System.out.println(str1);
I searched a lot but couldn't find any examples also.. please help.
Thanks in advance.
After lots of efforts I found that that documentation is wrong for Rest on fitness.org the parameter in the request is not 'content' but 'pageContent'...
Related
I am using SOAP UI 5.7.0 to mock a REST service and it is working fine. Only, when I want to access the body of a POST request with mockRequest.requestContent, the correct content is returned only in the first call, but from then on, it always returns the empty string.
I tried the call in OnRequestScript and in the POST requests own Dispatch script but the behavior is the same in both cases. I have the suspicion, that the Stream of the request is already read somewhere else and so does not return any more content. But I don't know what to do about it.
I wonder what is the correct way to read the content of a POST request.
Thank you
Appears to be a known issue, see posts in the community forum here and here.
this seems to be an old bug of PUT operation in REST mocks.
Unfortunately, this is a bug. There is an internal defect of SOAP-2344 for this issue. This applies for the PUT and DELETE methods for a REST mock service.
I have the same issue with a PATCH request.
Use the following trick to get the body of the PUT and DELETE requests:
mockRequest.with {
if (method.toString() == 'PUT' || method.toString() == 'DELETE') {
InputStreamReader isr = new InputStreamReader(request.getInputStream(), "UTF-8")
BufferedReader br = new BufferedReader(isr)
StringBuilder sb = new StringBuilder()
while ((s=br.readLine())!=null) {
sb.append(s)
}
def requestBody = new groovy.json.JsonSlurper().parseText(sb.toString())
log.info "requestBody: " + requestBody
}
}
I use it on the project but I don't really remember how where I got the snippet from. I had to change some parts to make it work as far as I remember. Give it a try.
Please take a look at the images. The response that I am getting on IBM UI side is not showing in the Java console. It is empty or null, but the intent is hit correctly.
I am developing a chatbot using the java watson conversation api, but I am facing an error while hitting the child node. Is it a context issue or something else? I am not able to figure it out. I attached the code.
Please help.
input_gui is user input
MessageRequest newMessage = new
MessageRequest.Builder().inputText(input_gui).context(context).build();
MessageResponse response = conversationService.message(workspaceId, newMessage).execute();
newMessage = new MessageRequest.Builder()
.inputText(input_gui)
.context(response.getContext()) // output context from the first message
.build();
System.out.println("watson response"+response);
Please look at image i am attaching. This image is .......
Here is working code I got my error I called service credential every time so context get initialize on every input message that why I am not able to get single conversation id in conversation now it's working
MessageRequest newMessage = new MessageRequest.Builder().inputText(input).context(context).build();
MessageResponse response = service.message(WORKSPACE_ID,newMessage).execute();
context = response.getContext();
System.out.println(response);
I'm not one expert in Java but, trying to help you, check the Java SDK examples for Watson Conversation. You can check out this project from IBM Developers, they are using Conversation Service with Java.
See the code that I did a few months ago for one test:
MessageRequest.Builder messageRequestBuilder = new MessageRequest.Builder();
messageRequestBuilder.inputText(input_gui);
messageRequestBuilder.context(question.context); //this context comes from a previous step
ServiceCall<MessageResponse> response = conversationService.message(workspaceId, messageRequestBuilder.build());
MessageResponse mAnswer = response.execute();
Object textObject = mAnswer.getOutput().get("text");
I'm a new guy on Angular 2, i get stuck on Angular Http post. I put all code HERE`
addHero(name: string): Observable<Hero>{
let body= JSON.stringify({name});
let headers = new Headers();
headers.append('Accept','application/json');
headers.append('Content-Type','application/json');
let options = new RequestOptions({ headers: headers });
console.log(body);
return this.http.post(this.heroesUrl, body, options).map(this.extractData).catch(this.handleError)
//return new Observable(name=>{id:3; name:name})
}
`
When i click on Add Hero button, it throw a bug as image below
enter image description here
Anyone know what wrong with this. Thank in advance
To post data you need to create an API or simulate one. According to the docs you can only use get from a .json file.
For learning angular 2 http I would suggest setting up an in memory api as in the tutorial. See the InMemoryDataService here: https://angular.io/docs/ts/latest/tutorial/toh-pt6.html
And more about how it works here: https://angular.io/docs/ts/latest/guide/server-communication.html#!#in-mem-web-api
And the working plunker from the tutorial: https://angular.io/resources/live-examples/toh-6/ts/plnkr.html
I have a question about Intuit API. I want to connect for the first time with this API. I'm using .NET SDK. I'm going througt this tutorial: http://goo.gl/PzIzoa . I don't know what i have to pass in arguments issuerId and subject (Step 1.b). I left them empty for the first try and I'm catching InvalidTokenException.
What arguments I have to pass to make it work?
Edit:
Thanks for your help, now I'm connecting via your web app.
Now I want to connect using my application. I wrote this code:
string certificateFile = "C:\\OpenSSL-Win32\\bin\\testapp1.crt";
string password = "xxx";
X509Certificate2 certificate = new X509Certificate2(certificateFile, password);
string consumerKey = "xxx";
string consumerSecret = "xxx";
string issuerId = "";
string subject = "";
SamlRequestValidator val = new SamlRequestValidator(certificate, consumerKey, consumerSecret, issuerId, subject);
After calling SamlRequestValidator constructor I'm catching InvalidTokenException. What am I doing wrong? What I have to do to make it work?
Please take a look at the following link.
https://developer.intuit.com/docs/0020_customeraccountdata/007_firstrequest
You can use apiexplorer tool to test these API calls without using devkit.
(It will ensure that your OAuth keys are working fine)
https://developer.intuit.com/apiexplorer?apiname=CustomerAccountData
You can refer the following .Net sample app as well.
https://developer.intuit.com/docs/0020_customeraccountdata/devkits/285.net_sample_app_for_cad_services
Let me know if you get any issue related to this process.
Thanks
Does anyone have a definitive way to post to a user's wall, using nothing but the .NET Framework, or Silverlight?
Problems deriving from people's attempts have been asked here on SO, but I cannot find a full, clear explanation of the Graph API spec and a simple example using WebClient or some similar class from System.Net.
Do I have to send all feed item properties as parameters in the query string? Can I construct a JSON object to represent the feed item and send that (with the access token as the only parameter)?
I expect its no more than a 5 line code snippet, else, point me at the spec in the FB docs.
Thanks for your help,
Luke
This is taken from how we post to a user's wall. We place the data for the post in the request body (I think we found this to be more reliable than including all the parameters in the query part of the request), it has the same format as a URL encoded query string.
I agree that the documentation is rather poor at explaining how to interact with a lot of resources. Typically I look at the documentation for information on fields and connections, then work with the Graph API Explorer to understand how the request needs to be constructed. Once I've got that down it's pretty easy to implement in C# or whatever. The only SDK I use is Facebook's Javascript SDK. I've found the others (especially 3rd party) are more complicated, buggy, or broken than rolling my own.
private void PostStatus (string accessToken, string userId)
{
UriBuilder address = new UriBuilder ();
address.Scheme = "https";
address.Host = "graph.facebook.com";
address.Path = userId + "/feed";
address.Query = "access_token=" + accessToken;
StringBuilder data = new StringBuilder ();
data.Append ("caption=" + HttpUtility.UrlEncodeUnicode ("Set by app to describe the app."));
data.Append ("&link=" + HttpUtility.UrlEncodeUnicode ("http://example.com/some_resource_to_go_to_when_clicked"));
data.Append ("&description=" + HttpUtility.UrlEncodeUnicode ("Message set by user."));
data.Append ("&name=" + HttpUtility.UrlEncodeUnicode ("App. name"));
data.Append ("&picture=" + HttpUtility.UrlEncodeUnicode ("http://example.com/image.jpg"));
WebClient client = new WebClient ();
string response = client.UploadString (address.ToString (), data.ToString ());
}
I don't know much about .net or silverlight, but the facebook api works with simple http requests.
All the different sdks (with the exception of the javascript one) are mainly just wrappers for the http requests with the "feature" of adding the access token to all requests.
Not in all requests the parameters are sent as querystring, in some POST requests you need to send them in the request body (application/x-www-form-urlencoded), and you can not send the data as json.
If the C# sdk is not to your liking, you can simply create one for your exact needs.
As I wrote, you just need to wrap the requests, and you can of course have a method that will get a json as parameter and will break it to the different parameters to be sent along with the request.
I would point you to the facebook documentation but you haven't asked anything specific so there's nothing to point you to except for the landing page.