0

When working through section 6.1 of the Recognition of hand-written digits with IBM Watson Machine Learning notebook, calling the Watson Machine Learning REST API to get the list of published models using:

GET /v3/wml_instances/{instance_id}/published_models

endpoint, there is a authorization (401) error with the following response text:

{"trace":"-1xmid60eblabs","errors":[{"code":"invalid_token_format","message":"Invalid token format. Bearer token format should be used.","target":{"type":"header","name":"Authorization"}}]}

The previous REST API call in the notebook to get the instance details using the authorization token returned from the /v3/identity/token endpoint worked ok.

Looks like an error in the notebook. Did the API authorization scheme change breaking the notebook?

timro
  • 36
  • 1
  • 6
  • Hi Tim. Can you please update your question with a link to the section that you are referencing? Thanks! – William 'Bill' Wentworth Aug 17 '17 at 19:19
  • 1
    Hi Bill, this is a community notebook that gets linked from the Manage control pane from a Bluemix Watson Machine Learning control panel. Links are user/instance specific. In parallel, I've been in touch with the team and they've just updated this and a couple of other affected community notebooks for ML. – timro Aug 17 '17 at 21:50

1 Answers1

0

This endpoint in the REST API appears to be expecting authentication of the form Authorization: <type> <credentials> per W3C in HTTP 1.0

I updated the notebook code to add the type in the Authorization field of the header:

header = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + mltoken}

The rest of the Watson Machine Learning API calls to create the online deployment and score new data use the same header in the notebook and all execute correctly.

Community
  • 1
  • 1
timro
  • 36
  • 1
  • 6
  • This fix has been applied to the following notebooks as of 8/17/17 Recognition of hand-written digits with IBM Watson Machine Learning, Predictive modeling with IBM Watson Machine Learning using Python, and Predictive modeling with IBM Watson Machine Learning with Scala – timro Aug 17 '17 at 21:52