Digital Developer Conference: a FREE half-day online conference focused on AI & Cloud – North America: Nov 2 – India: Nov 9 – Europe: Nov 14 – Asia Nov 23 Register now

Close outline
  • United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

How to obtain valid credentials for Document Conversion service

120000BMT9 gravatar image
Question by KeithCramer  (1) | Sep 21, 2015 at 11:33 AM mqdatamqseriesibmcloudconversionchannel

I am trying to call the Data Conversion service from a Java program: http://document-conversion-demo.mybluemix.net I tried using my bluemix credentials but this is not working or correct. What is the correct process to obtain valid credentials to use this service?

This is my trap using bluemix valid credentials

Sep 21, 2015 10:46:54 AM com.ibm.watson.developer_cloud.service.WatsonService execute SEVERE: HTTP Status: 401, message: null Exception in thread "main" com.ibm.watson.developer_cloud.service.UnauthorizedException: Unauthorized: Access is denied due to invalid credentials at com.ibm.watson.developer_cloud.service.WatsonService.execute(WatsonService.java:198) at com.ibm.watson.developer_cloud.document_conversion.v1.DocumentConversion.execute(DocumentConversion.java:254) at com.ibm.watson.developer_cloud.document_conversion.v1.helpers.ConvertDocumentHelper.convertDocument(ConvertDocumentHelper.java:122) at com.ibm.watson.developer_cloud.document_conversion.v1.helpers.ConvertDocumentHelper.convertDocument(ConvertDocumentHelper.java:88) at com.ibm.watson.developer_cloud.document_conversion.v1.helpers.ConvertDocumentHelper.convertDocumentToAnswer(ConvertDocumentHelper.java:70) at com.ibm.watson.developer_cloud.document_conversion.v1.DocumentConversion.convertDocumentToAnswer(DocumentConversion.java:193)

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

2 answers

  • Sort: 
270006STTC gravatar image

Answer by Leo Kenji (428) | Sep 21, 2015 at 01:52 PM

You must first add the service to your bluemix application.

After that, your code will get the credentials dynamically from the system environment variable called VCAP_SERVICES

 System.getenv("VCAP_SERVICES");

VCAP_SERVICES is a string in the JSON format that contains an entry for each service bound to your application, for example

   {
   "document_conversion": [
     {
       "name": "docConv",
       "label": "document_conversion",
       "plan": "experimental",
       "credentials": {
         "url": "https://gateway.watsonplatform.net/document-conversion-experimental/api",
         "username": "****",
         "password": "****"
       }
     }
   ]
 }

so you have to parse this JSON and extract your credentials from there.

In my case, for example, I use flexjson, but could be any other JSON library (GSON, Jackson, whatever)

 private static final JSONDeserializer<Map<String, List<Map<String, Map<String, String>>>>> json = new JSONDeserializer<>();
 
 String username = dto.setUsername(map.get("document_conversion").get(0).get("credentials")
                 .get("username"));

 String password = dto.setUsername(map.get("document_conversion").get(0).get("credentials")
                 .get("password"));


An then you can use the excellent java-wrappers library (as it seems you're already using)

 import com.ibm.watson.developer_cloud.document_conversion.v1.DocumentConversion;
 import com.ibm.watson.developer_cloud.document_conversion.v1.model.DocumentCollection;
 import java.util.HashMap;
 import java.util.Map;
 
 DocumentConversion service = new DocumentConversion();
 service.setUsernameAndPassword(username, password);
 
 Map<String, Object> docListParams = new HashMap<String, Object>();
 docListParams.put(DocumentConversion.LIMIT, 10);
 DocumentCollection documentCollection = service.getDocumentCollection(docListParams);
 System.out.println(documentCollection);

Notice that, if I am not wrong, password are periodicaly rotated in bluemix, so you must avoid using hardcoded ones.

Comment
Bill Wentworth
MattFulgo

People who like this

  2   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
2700060R2K gravatar image

Answer by William_von_Hagen (626) | Sep 21, 2015 at 08:50 PM

The WDC docs contain a getting started section (Docs -> Getting Started) that we typically link to from service docs or excerpt from as the first step of our tutorials. It looks as though we didn't do that for the Doc Conversion tutorial and docs. Thanks for pointing that out - we will fix that. It contains sections on obtaining Bluemix credentials, discusses the VCAP_SERVICES environment variable, and also explains how to get and examine credentials within the Bluemix web interface. Comments welcome, and sorry that this information was hard to find in this case.

Comment
Bill Wentworth
MattFulgo

People who like this

  2   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

48 people are following this question.

Answers

Answers & comments

Related questions

Why are we seeing CSQX541E for a client connection using data conversion ? 1 Answer

In my queue manager error logs i am seeing AMQ9780 and AMQ9519 being reported on a channel name I do not recognize. 1 Answer

what is reason and why qmgr certificate should be received not be added me mq ssl? 1 Answer

why qmgr certificate should be received not to be added in mq ssl what is the reason behind it? 1 Answer

CSQX014E listener exceeded channel limit, TRPTYPE=TCP,INDISP=disposition 1 Answer

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • Data and AI
  • DataPower
  • Decision Optimization
  • DevOps Build
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • Hyper Protect
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PartnerWorld Developer Support
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges