
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2020 09:42 PM
I've been trying to get the HTTP request proxy to work and so far it's working perfectly in the instance once deployed but I suspect there's something wrong with my proxy configuration because it's not authenticating when I run "now-cli develop".
now-cli.json is:
{
"development": {
"proxy": {
"origin": "https://dev100***service-now.com",
"headers": {
"Authorization": "Basic SGFoYSB5b3UgdGhpbmsgdGhpcyB3b3VsZCBiZSBteSByZWFsIHBhc3N3b3J"
},
"proxies": ["*"]
},
}
const fetchUserEffect = createHttpEffect('/api/now/table/sys_user?sysparm_limit=1', {
method: 'GET',
successActionType: USER_FETCH_SUCCESS,
errorActionType: USER_FETCH_ERROR
});
Solved! Go to Solution.
- Labels:
-
Now Experience UI Framework
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2020 02:54 PM
Hey royjustus!
I just successfully did a GET call from my now-cli project after hours and hours of pain.
What I have come to realize is that now-cli completely ignores the now-cli.json file and anything you do in it except if you change your port, then it gets confused.
What I did to solve the problem. Is that I had to add my instance to the api request, AS WELL AS adding cors anywhere from heroku to get around cors errors.
I ALSO directly added my authorization into the header in the request, as again, the now-cli ignores the .json file. Atleast when in develop mode.
const fetchUserEffect = createHttpEffect(
"https://cors-anywhere.herokuapp.com/https://dev11111.service-now.com/api/now/table/sys_user?sysparm_limit=10",
{
method: "GET",
successActionType: "USER_FETCH_SUCCESS",
errorActionType: "USER_FETCH_ERROR",
batch: false,
headers: {
Authorization: "Basic bmljZXVzZXJuYW1laGVyZ3dvcmRoZXJl=",
},
}
);
This went straight through and was accepted.
instance id and auth key has been changed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 05:32 AM
I have almost the same problem. For me httpEffect does not work at all either locally or deployed. The actions are never dispatched and there no http request sent. Apparently there is something wrong with the ui-http-effect package since we are not the only ones with issues..
For now I replaced it with the other example that uses the fetch function and that works fine! Although I could not make it work locally since the fetch method uses a relative url which is sent on the same host/port and when running locally the proxy does not work with the same port (I think you saw my question here).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 07:17 AM
Yeah so for my the actions do get dispatched (key is to put the dispatch call in the view) minimal code is:
const USER_FETCH_SUCCESS = 'USER_FETCH_SUCCESS'
const USER_FETCH_ERROR = 'USER_FETCH_ERROR'
const view = (state, {updateState, dispatch}) => {
console.log("Trying");
dispatch("USER_FETCH_REQUESTED");
console.log("Tried");
return (<div>holder</div>);
};
const fetchUserEffect = createHttpEffect('/api/now/table/sys_user?sysparm_limit=1', {
method: 'GET',
successActionType: USER_FETCH_SUCCESS,
errorActionType: USER_FETCH_ERROR,
batch: false
});
createCustomElement('x-8011-card', {
renderer: {type: snabbdom},
view,
styles,
actionHandlers: {
'USER_FETCH_REQUESTED': fetchUserEffect,
[USER_FETCH_SUCCESS]: ({action, updateState}) => {console.log("USER_FETCH_SUCCESS");},
[USER_FETCH_ERROR]: ({action, updateState}) => {console.log("USER_FETCH_ERROR");}
}
});
Interestingly the proxy config I specified seems to just work, the 401 response I'm getting comes from the ServiceNow Server so it's figuring that part out. Really the only major remaining issue for me is that the authorization headers don't get added. (See attachment for headers on the response object)
Regards,
Roy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 09:18 AM
Did you figure out why your data request was not being properly authenticated? I'm having the same issue, the request is being sent to the instance but I'm getting a 401 back.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 10:11 AM
No luck yet. I'm working around it by just repeatedly deploying to my instance instead of developing locally if I need the data connections to work.
Hopefully someone can shed some light on the situation.