IBM Watson. MessageRequest.Builder() issue - android

I am working on building an Android app which uses the Watson Conversation API. I am following the tutorials mentioned here and here.
However, it seems that quite a few of the Api's functions are deprecated. For example, the ConversationService is now Conversation.
Similarly, I am having an issue running this piece of code:
MessageRequest request = new MessageRequest.Builder()
.inputText(userStatement)
.build();
It says Cannot resolve symbol Builder. Since the MessageRequest Class no longer has the builder(I guess). Any way around this situation?

Try it..
MessageOptions newMessage = new MessageOptions.Builder().workspaceId("")
.input(new InputData.Builder(userStatement).build()).context(context).build();
MessageResponse response = service.message(newMessage).execute();
I think you are using older version of sdk.
Update it https://github.com/watson-developer-cloud/java-sdk/releases
Message request is no longer available. Use MessageOptions.

Related

Microsoft Azure Translator Android API not working

I was trying to make a text translator app using Microsoft-translator-API but I am not able to receive any response from this API, I always get this message:
[microsoft-translator-api] Error retrieving translation: Unable to resolve host "datamarket.accesscontrol.windows.net": No address associated with hostname
even I have given correct client Id and client secret Id.
I tried this link but I don't know where to put the JSON-Simple.jar file. I tried this link too but still with no success. I am pasting my code below:
public String translateText() throws Exception {
Translate.setClientId("whateveritis");
Translate.setClientSecret("whateveritis");
translatedText = Translate.execute(
userText.getText().toString(),
languages[sEnterLan.getSelectedItemPosition()],
languages[sTransLan.getSelectedItemPosition()]);
Language detectedLanguage = Detect.execute(userText.getText()
.toString());
this.detectedLanguage = detectedLanguage.getName(Language.ENGLISH);
return translatedText;
}
By calling above function I can receive the translated text into a string variable but every time I get an exception.
According to your code and reference links, I think you were using the third party Java wrapper boatmeme/microsoft-translator-java-api for MS Azure Translator API. However, it's an old Java wrapper which wrappered the old & unavailable APIs from the old site Azure datamarket. There is a notice at this site, and all origin APIs had been migrated to Azure subscription.
DataMarket and Data Services are being retired and will stop accepting new orders after 12/31/2016. Existing subscriptions will be retired and cancelled starting 3/31/2017. Please reach out to your service provider for options if you want to continue service.
So I suggested that you can try to refer to my answer for the other SO thread Microsoft Translator API Java, How to get client new ID with Azure to create a cognitive service for Translator Text API on Azure portal and use it via the new REST APIs.
Hope it helps.

Error 403 with Android restricted Cloud Platform API key and Cloud Endpoints

I have a problem restricting a Google Cloud Platform API key usage to an Android app: I have added its package name and certificate SHA-1 fingerprint (the debug one to get started) but it doesn't work.
The error I get when calling any API is
403 Requests from this Android client application <empty> are blocked.
I'm calling the APIs by using a Cloud Endpoints generated client lib, and I've not been able to find any method that I can use at initialisation time to set the app credentials, nor does it do it by itself (as I can guess from the "<empty>" in the error).
I can't find any useful info in any documentation as well, as far as I've red it seems like it should do it by itself.
This is my init code:
MyApi.Builder builder = new MyApi.Builder(new NetHttpTransport(), new AndroidJsonFactory(), null)
.setApplicationName("<my package name>")
.setRootUrl(<my root URL>)
.setGoogleClientRequestInitializer(new MyApiRequestInitializer(<my API key>));
I've also tried what suggested in this answer but nothing changed.
Is there any passage I'm missing? How should it be done?
I believe the problem appears only in emulators. I am getting the same error when running my app in an emulator. However, on real devices I do not seem to have the problem. Have you tested it on a real device?

Google Safe Browsing API v2 sample Implementation Android

I am trying to implement a Sample application in Android which gets the malware and phishing list from safe Browsing API and checks the authenticity of URL, this is client side method, but I am constantly getting 400 (Bad Request) as response code when I am trying to hit the URL.
Searched throughout the internet but couldn't get any sample working code.
Even on Developer's Guide page https://developers.google.com/safe-browsing/developers_guide_v2 it is not mentioned how to send the list name correctly in POST request for downloading or updating.
Please help me by providing the correct procedure of how to send list name (if code snippet can be posted, it would be great as I am new to Android.)
Check out that request should end with '\n'. It is common to ignore this. I hope it helps.

Working with android and redmine restapi to log time

i m working on a app that can log time using redmine.
for now i can receive the projects, but i have no idea about log the time.
there is a restapi of redmine, but i dont find any answers...:
http://www.redmine.org/projects/redmine/wiki/Rest_api
regards,
kai
You could follow what the redmine-java-api does. Unfortunately the redmine-java-api doesn't work out of the box on android but it can be modified to do so. See my answer here.
Alternatively follow this answer on how to make a HTTP request and make a request by:
new RequestTask().execute("http://demo.redmine.org/time_entries.json");
Then, to make a POST request follow this guide

App engine connected Android app

Problem with the new App engine connected android application projects for the google eclipse plugin? This is the "Big Daddy" sample shown at goolge i/o 2011. My sample project compiles and the android app appears to work fine and registers with the server. However when I send a message from the server I get the following: Having issue with sample project. Android appears to work fine and registers with the server and the c2dm server, however I cannot send a message.
Also of note on the server is a c2dmconfig datastore object. It has fields for authToken and c2dmUrl. The authToken has a token, however the c2dmUrl is NULL. I suspect this is where my problem lies, but not sure how to fix it.
Thanks Patrick
I found this question by wondering the same thing, if the c2dmUrl being null is a problem. It would seem that this is not an issue though. If you look at the C2DMConfig (the entity that you are referencing), there is a function called "getC2DMUrl". Here it is:
public String getC2DMUrl() {
if (c2dmUrl == null) {
return DATAMESSAGING_SEND_ENDPOINT;
} else {
return c2dmUrl;
}
So null is a supported value for this. If a specific URL isn't specified, it simply returns it to the default.

Categories

Resources