API call IBM Watson Natural Language Understanding-xq - Python or Postman
I'm struggling to connect to the IBM Watson API for Natural Language Understanding.
I've added it to the Resource list in my IAM account. I've got to the page with an example POST request to connect to the API, and I can't seem to authenticate. I've blanked out the API key from this request but in the pages the key is supplied so I'm struggling to see why it's not working
curl -X POST -u "#######"
-H "Content-Type: application/json"
-d '{ "text": "I still have a dream. It is a dream deeply rooted in the
American dream. I have a dream that one day this nation will rise up and
live out the true meaning of its creed: "We hold these truths to be
self-evident, that all men are created equal."", "features": {
"sentiment": {}, "keywords": {} }}'
"https://gateway-lon.watsonplatform.net/natural-language-
understanding/api/v1/analyze?version=2018-03-19"
I've tried pasting this into Postman but I just get a 401 Unauthorized response, which makes me think it's something in the account pages of the IAM, but they've chnage the interface and not update the documentation, and I'm going round in circles because the instructions don't match the menus.
Any pointers would be appreciated. I intend to query through Python, so I'm hoping once I can get past the authentication issue it's as simple as copying the Python code out of Postman
python-3.x api nlp ibm-watson
add a comment |
I'm struggling to connect to the IBM Watson API for Natural Language Understanding.
I've added it to the Resource list in my IAM account. I've got to the page with an example POST request to connect to the API, and I can't seem to authenticate. I've blanked out the API key from this request but in the pages the key is supplied so I'm struggling to see why it's not working
curl -X POST -u "#######"
-H "Content-Type: application/json"
-d '{ "text": "I still have a dream. It is a dream deeply rooted in the
American dream. I have a dream that one day this nation will rise up and
live out the true meaning of its creed: "We hold these truths to be
self-evident, that all men are created equal."", "features": {
"sentiment": {}, "keywords": {} }}'
"https://gateway-lon.watsonplatform.net/natural-language-
understanding/api/v1/analyze?version=2018-03-19"
I've tried pasting this into Postman but I just get a 401 Unauthorized response, which makes me think it's something in the account pages of the IAM, but they've chnage the interface and not update the documentation, and I'm going round in circles because the instructions don't match the menus.
Any pointers would be appreciated. I intend to query through Python, so I'm hoping once I can get past the authentication issue it's as simple as copying the Python code out of Postman
python-3.x api nlp ibm-watson
2
Have you tried the python SDK? github.com/watson-developer-cloud/python-sdk
– Simon O'Doherty
Jan 2 at 11:28
No, getting the Python working was step 2 I'm stuck on step 1 which is testing the API authentication using Postman. I tend to check my authentication is working first before I work on the Python code, then I can isolate which element is failing. I'll give it ago though because your link seems to suggest the SDK seems to look after handling the token ... so thanks, I'll let you know ...
– Stuart Kirkup
Jan 2 at 13:42
I had a go but got "raise WatsonApiException(response.status_code, message=error_message, httpResponse=response) watson_developer_cloud.watson_service.WatsonApiException: Error: Provided API key could not be found, Code: 400"
– Stuart Kirkup
Jan 3 at 17:57
Got it working. Many thanks. See my answer below about deleting and recreating the API key
– Stuart Kirkup
Jan 3 at 20:23
add a comment |
I'm struggling to connect to the IBM Watson API for Natural Language Understanding.
I've added it to the Resource list in my IAM account. I've got to the page with an example POST request to connect to the API, and I can't seem to authenticate. I've blanked out the API key from this request but in the pages the key is supplied so I'm struggling to see why it's not working
curl -X POST -u "#######"
-H "Content-Type: application/json"
-d '{ "text": "I still have a dream. It is a dream deeply rooted in the
American dream. I have a dream that one day this nation will rise up and
live out the true meaning of its creed: "We hold these truths to be
self-evident, that all men are created equal."", "features": {
"sentiment": {}, "keywords": {} }}'
"https://gateway-lon.watsonplatform.net/natural-language-
understanding/api/v1/analyze?version=2018-03-19"
I've tried pasting this into Postman but I just get a 401 Unauthorized response, which makes me think it's something in the account pages of the IAM, but they've chnage the interface and not update the documentation, and I'm going round in circles because the instructions don't match the menus.
Any pointers would be appreciated. I intend to query through Python, so I'm hoping once I can get past the authentication issue it's as simple as copying the Python code out of Postman
python-3.x api nlp ibm-watson
I'm struggling to connect to the IBM Watson API for Natural Language Understanding.
I've added it to the Resource list in my IAM account. I've got to the page with an example POST request to connect to the API, and I can't seem to authenticate. I've blanked out the API key from this request but in the pages the key is supplied so I'm struggling to see why it's not working
curl -X POST -u "#######"
-H "Content-Type: application/json"
-d '{ "text": "I still have a dream. It is a dream deeply rooted in the
American dream. I have a dream that one day this nation will rise up and
live out the true meaning of its creed: "We hold these truths to be
self-evident, that all men are created equal."", "features": {
"sentiment": {}, "keywords": {} }}'
"https://gateway-lon.watsonplatform.net/natural-language-
understanding/api/v1/analyze?version=2018-03-19"
I've tried pasting this into Postman but I just get a 401 Unauthorized response, which makes me think it's something in the account pages of the IAM, but they've chnage the interface and not update the documentation, and I'm going round in circles because the instructions don't match the menus.
Any pointers would be appreciated. I intend to query through Python, so I'm hoping once I can get past the authentication issue it's as simple as copying the Python code out of Postman
python-3.x api nlp ibm-watson
python-3.x api nlp ibm-watson
asked Jan 2 at 11:10
Stuart KirkupStuart Kirkup
607
607
2
Have you tried the python SDK? github.com/watson-developer-cloud/python-sdk
– Simon O'Doherty
Jan 2 at 11:28
No, getting the Python working was step 2 I'm stuck on step 1 which is testing the API authentication using Postman. I tend to check my authentication is working first before I work on the Python code, then I can isolate which element is failing. I'll give it ago though because your link seems to suggest the SDK seems to look after handling the token ... so thanks, I'll let you know ...
– Stuart Kirkup
Jan 2 at 13:42
I had a go but got "raise WatsonApiException(response.status_code, message=error_message, httpResponse=response) watson_developer_cloud.watson_service.WatsonApiException: Error: Provided API key could not be found, Code: 400"
– Stuart Kirkup
Jan 3 at 17:57
Got it working. Many thanks. See my answer below about deleting and recreating the API key
– Stuart Kirkup
Jan 3 at 20:23
add a comment |
2
Have you tried the python SDK? github.com/watson-developer-cloud/python-sdk
– Simon O'Doherty
Jan 2 at 11:28
No, getting the Python working was step 2 I'm stuck on step 1 which is testing the API authentication using Postman. I tend to check my authentication is working first before I work on the Python code, then I can isolate which element is failing. I'll give it ago though because your link seems to suggest the SDK seems to look after handling the token ... so thanks, I'll let you know ...
– Stuart Kirkup
Jan 2 at 13:42
I had a go but got "raise WatsonApiException(response.status_code, message=error_message, httpResponse=response) watson_developer_cloud.watson_service.WatsonApiException: Error: Provided API key could not be found, Code: 400"
– Stuart Kirkup
Jan 3 at 17:57
Got it working. Many thanks. See my answer below about deleting and recreating the API key
– Stuart Kirkup
Jan 3 at 20:23
2
2
Have you tried the python SDK? github.com/watson-developer-cloud/python-sdk
– Simon O'Doherty
Jan 2 at 11:28
Have you tried the python SDK? github.com/watson-developer-cloud/python-sdk
– Simon O'Doherty
Jan 2 at 11:28
No, getting the Python working was step 2 I'm stuck on step 1 which is testing the API authentication using Postman. I tend to check my authentication is working first before I work on the Python code, then I can isolate which element is failing. I'll give it ago though because your link seems to suggest the SDK seems to look after handling the token ... so thanks, I'll let you know ...
– Stuart Kirkup
Jan 2 at 13:42
No, getting the Python working was step 2 I'm stuck on step 1 which is testing the API authentication using Postman. I tend to check my authentication is working first before I work on the Python code, then I can isolate which element is failing. I'll give it ago though because your link seems to suggest the SDK seems to look after handling the token ... so thanks, I'll let you know ...
– Stuart Kirkup
Jan 2 at 13:42
I had a go but got "raise WatsonApiException(response.status_code, message=error_message, httpResponse=response) watson_developer_cloud.watson_service.WatsonApiException: Error: Provided API key could not be found, Code: 400"
– Stuart Kirkup
Jan 3 at 17:57
I had a go but got "raise WatsonApiException(response.status_code, message=error_message, httpResponse=response) watson_developer_cloud.watson_service.WatsonApiException: Error: Provided API key could not be found, Code: 400"
– Stuart Kirkup
Jan 3 at 17:57
Got it working. Many thanks. See my answer below about deleting and recreating the API key
– Stuart Kirkup
Jan 3 at 20:23
Got it working. Many thanks. See my answer below about deleting and recreating the API key
– Stuart Kirkup
Jan 3 at 20:23
add a comment |
2 Answers
2
active
oldest
votes
Your -u credentials should be:
-u "apikey:#######"
As per the API documentation -
https://cloud.ibm.com/apidocs/natural-language-understanding#authentication
Yes I was being over zealous with me #### out the apikey, the IBM website includes -u "apikey:#######" in the curl code iexample, and that's what I was trying to use. Postman doesn't cope with the -u element of the code when I paste it directly from the IBM site. The authorization in Postman is "Inherit auth from parent" and I'm unsure how to generate the -u part in the Postmaninterface. If anyone has suggestions that would at least mean I can get a valid response and not an authorization error. Currently I can't completely rule out whether it's my IAM account setup at fault.
– Stuart Kirkup
Jan 3 at 15:47
add a comment |
Somehow the API credentials were not being recognised. I must have done something wrong in the initial IAM setup, which meant that when I deleted the credentials, re-created them and then copied the new key ... everything immediately started working. Complete mystery as to why but hopefully this helps someone. Here are the instructions I followed
https://console.bluemix.net/docs/services/natural-language-understanding/getting-started.html#getting-started-tutorial
I used the SDK as suggested by Simon O'Doherty
It might also be related to me having gone into the "Manage" >> "Account" and deleted any Access Groups and Service IDs I'd attempted to create by following the "Getting Started with IAM" instructions from here, which I suspect might have been what confused me
IAM getting started (not required)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54005255%2fapi-call-ibm-watson-natural-language-understanding-xq-python-or-postman%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your -u credentials should be:
-u "apikey:#######"
As per the API documentation -
https://cloud.ibm.com/apidocs/natural-language-understanding#authentication
Yes I was being over zealous with me #### out the apikey, the IBM website includes -u "apikey:#######" in the curl code iexample, and that's what I was trying to use. Postman doesn't cope with the -u element of the code when I paste it directly from the IBM site. The authorization in Postman is "Inherit auth from parent" and I'm unsure how to generate the -u part in the Postmaninterface. If anyone has suggestions that would at least mean I can get a valid response and not an authorization error. Currently I can't completely rule out whether it's my IAM account setup at fault.
– Stuart Kirkup
Jan 3 at 15:47
add a comment |
Your -u credentials should be:
-u "apikey:#######"
As per the API documentation -
https://cloud.ibm.com/apidocs/natural-language-understanding#authentication
Yes I was being over zealous with me #### out the apikey, the IBM website includes -u "apikey:#######" in the curl code iexample, and that's what I was trying to use. Postman doesn't cope with the -u element of the code when I paste it directly from the IBM site. The authorization in Postman is "Inherit auth from parent" and I'm unsure how to generate the -u part in the Postmaninterface. If anyone has suggestions that would at least mean I can get a valid response and not an authorization error. Currently I can't completely rule out whether it's my IAM account setup at fault.
– Stuart Kirkup
Jan 3 at 15:47
add a comment |
Your -u credentials should be:
-u "apikey:#######"
As per the API documentation -
https://cloud.ibm.com/apidocs/natural-language-understanding#authentication
Your -u credentials should be:
-u "apikey:#######"
As per the API documentation -
https://cloud.ibm.com/apidocs/natural-language-understanding#authentication
answered Jan 2 at 17:17


chughtschughts
1,1551516
1,1551516
Yes I was being over zealous with me #### out the apikey, the IBM website includes -u "apikey:#######" in the curl code iexample, and that's what I was trying to use. Postman doesn't cope with the -u element of the code when I paste it directly from the IBM site. The authorization in Postman is "Inherit auth from parent" and I'm unsure how to generate the -u part in the Postmaninterface. If anyone has suggestions that would at least mean I can get a valid response and not an authorization error. Currently I can't completely rule out whether it's my IAM account setup at fault.
– Stuart Kirkup
Jan 3 at 15:47
add a comment |
Yes I was being over zealous with me #### out the apikey, the IBM website includes -u "apikey:#######" in the curl code iexample, and that's what I was trying to use. Postman doesn't cope with the -u element of the code when I paste it directly from the IBM site. The authorization in Postman is "Inherit auth from parent" and I'm unsure how to generate the -u part in the Postmaninterface. If anyone has suggestions that would at least mean I can get a valid response and not an authorization error. Currently I can't completely rule out whether it's my IAM account setup at fault.
– Stuart Kirkup
Jan 3 at 15:47
Yes I was being over zealous with me #### out the apikey, the IBM website includes -u "apikey:#######" in the curl code iexample, and that's what I was trying to use. Postman doesn't cope with the -u element of the code when I paste it directly from the IBM site. The authorization in Postman is "Inherit auth from parent" and I'm unsure how to generate the -u part in the Postmaninterface. If anyone has suggestions that would at least mean I can get a valid response and not an authorization error. Currently I can't completely rule out whether it's my IAM account setup at fault.
– Stuart Kirkup
Jan 3 at 15:47
Yes I was being over zealous with me #### out the apikey, the IBM website includes -u "apikey:#######" in the curl code iexample, and that's what I was trying to use. Postman doesn't cope with the -u element of the code when I paste it directly from the IBM site. The authorization in Postman is "Inherit auth from parent" and I'm unsure how to generate the -u part in the Postmaninterface. If anyone has suggestions that would at least mean I can get a valid response and not an authorization error. Currently I can't completely rule out whether it's my IAM account setup at fault.
– Stuart Kirkup
Jan 3 at 15:47
add a comment |
Somehow the API credentials were not being recognised. I must have done something wrong in the initial IAM setup, which meant that when I deleted the credentials, re-created them and then copied the new key ... everything immediately started working. Complete mystery as to why but hopefully this helps someone. Here are the instructions I followed
https://console.bluemix.net/docs/services/natural-language-understanding/getting-started.html#getting-started-tutorial
I used the SDK as suggested by Simon O'Doherty
It might also be related to me having gone into the "Manage" >> "Account" and deleted any Access Groups and Service IDs I'd attempted to create by following the "Getting Started with IAM" instructions from here, which I suspect might have been what confused me
IAM getting started (not required)
add a comment |
Somehow the API credentials were not being recognised. I must have done something wrong in the initial IAM setup, which meant that when I deleted the credentials, re-created them and then copied the new key ... everything immediately started working. Complete mystery as to why but hopefully this helps someone. Here are the instructions I followed
https://console.bluemix.net/docs/services/natural-language-understanding/getting-started.html#getting-started-tutorial
I used the SDK as suggested by Simon O'Doherty
It might also be related to me having gone into the "Manage" >> "Account" and deleted any Access Groups and Service IDs I'd attempted to create by following the "Getting Started with IAM" instructions from here, which I suspect might have been what confused me
IAM getting started (not required)
add a comment |
Somehow the API credentials were not being recognised. I must have done something wrong in the initial IAM setup, which meant that when I deleted the credentials, re-created them and then copied the new key ... everything immediately started working. Complete mystery as to why but hopefully this helps someone. Here are the instructions I followed
https://console.bluemix.net/docs/services/natural-language-understanding/getting-started.html#getting-started-tutorial
I used the SDK as suggested by Simon O'Doherty
It might also be related to me having gone into the "Manage" >> "Account" and deleted any Access Groups and Service IDs I'd attempted to create by following the "Getting Started with IAM" instructions from here, which I suspect might have been what confused me
IAM getting started (not required)
Somehow the API credentials were not being recognised. I must have done something wrong in the initial IAM setup, which meant that when I deleted the credentials, re-created them and then copied the new key ... everything immediately started working. Complete mystery as to why but hopefully this helps someone. Here are the instructions I followed
https://console.bluemix.net/docs/services/natural-language-understanding/getting-started.html#getting-started-tutorial
I used the SDK as suggested by Simon O'Doherty
It might also be related to me having gone into the "Manage" >> "Account" and deleted any Access Groups and Service IDs I'd attempted to create by following the "Getting Started with IAM" instructions from here, which I suspect might have been what confused me
IAM getting started (not required)
answered Jan 3 at 20:22
Stuart KirkupStuart Kirkup
607
607
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54005255%2fapi-call-ibm-watson-natural-language-understanding-xq-python-or-postman%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Have you tried the python SDK? github.com/watson-developer-cloud/python-sdk
– Simon O'Doherty
Jan 2 at 11:28
No, getting the Python working was step 2 I'm stuck on step 1 which is testing the API authentication using Postman. I tend to check my authentication is working first before I work on the Python code, then I can isolate which element is failing. I'll give it ago though because your link seems to suggest the SDK seems to look after handling the token ... so thanks, I'll let you know ...
– Stuart Kirkup
Jan 2 at 13:42
I had a go but got "raise WatsonApiException(response.status_code, message=error_message, httpResponse=response) watson_developer_cloud.watson_service.WatsonApiException: Error: Provided API key could not be found, Code: 400"
– Stuart Kirkup
Jan 3 at 17:57
Got it working. Many thanks. See my answer below about deleting and recreating the API key
– Stuart Kirkup
Jan 3 at 20:23