Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with RestClient #16

Closed
victorvelasquez96 opened this issue Mar 3, 2022 · 11 comments
Closed

Problem with RestClient #16

victorvelasquez96 opened this issue Mar 3, 2022 · 11 comments

Comments

@victorvelasquez96
Copy link

Hi,
sorry for the inconvenience.

I have an error on this part of the code that retrives the info of all apps:
_var rsp = restClient.Get<JArray>("/qrs/app/hublist/full");_

We i use this on my localhost it does work but on another server this is the response:
_Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0._

I tried to convert the response into an JObject or a Simple String but nothing works.

This Error is caused by Qlik?

Thanks

@kolsrud
Copy link
Owner

kolsrud commented Mar 3, 2022

Hi! I've never run into that myself, but the error message seems to indicate that you are getting some invalid json there. What do you get if you just use the Get method without a type parameter, like this?

var rsp = restClient.Get("/qrs/app/hublist/full");
Console.WriteLine(rsp);

@kolsrud
Copy link
Owner

kolsrud commented Mar 3, 2022

I see that I get a Json parse error if I am not correctly authenticated. So you should probably look at how you are setting up the authentication of your RestClient instance.

@victorvelasquez96
Copy link
Author

I see that I get a Json parse error if I am not correctly authenticated. So you should probably look at how you are setting up the authentication of your RestClient instance.

HI guys,
sorry if I answer only now.

Kolsrud was right, i'm unauthorized.

Question: could the virtual proxy present in the qmc be the problem? At the moment my connection is through NTLM data. I need to put in the URI-->https://ip/prefix?

@kolsrud
Copy link
Owner

kolsrud commented Mar 7, 2022

@victorvelasquez96 The virtual proxy is what controls the authentication method, so if the default URL does not support NTLM, then you'll need to add the virtual proxy prefix to your URL like you suggest. So instead of

var client = new RestClient("https://ip");

you would need to do

var client = new RestClient("https://ip/prefix");

Then the rest of the flow will be the the same as before. So in your case it should probably look something like this:

var client = new RestClient("https://ip/prefix");
client.AsNtlmUserViaProxy();
var rsp = client.Get<JArray>("/qrs/app/hublist/full");

@victorvelasquez96
Copy link
Author

victorvelasquez96 commented Mar 7, 2022

Hi,
@kolsrud

Thanks for the advice!

In my local host it works perfecty but on another server it gaves me this error-> (i use the vpn of the company, but the program is on the machine)

1

this is the setting of the proxy on the machine

Screenshot_2

My code ( i tried a simply "about" but as you see the response it's different from a json like response):

 var senseServerUrl = domain;
           // ip = https://companyurl.domain.com/connect
            var uri = new Uri(senseServerUrl);
            var restClient = new RestClient(senseServerUrl);
            var networkCredentials = new NetworkCredential(user, password, userDomain);
            restClient.AsNtlmUserViaProxy(networkCredentials, certificateValidation:false);
           var rsp = restClient.Get("/qrs/about");
           Console.WriteLine(rsp);

Do you think that i need to modify the header like this? -->

restClient.CustomHeaders["XX-Qlik-Security"] = "Context=ManagementAccess";

Thanks,
Victor

@kolsrud
Copy link
Owner

kolsrud commented Mar 8, 2022

No, it's not necessary to change that header.

I take it the variable "domain" is equal to the value you have for "ip" in your comment?
What happens if you simply copy the "ip" you use to a browser? Does it work?

@victorvelasquez96
Copy link
Author

victorvelasquez96 commented Mar 8, 2022

No, it's not necessary to change that header.

I take it the variable "domain" is equal to the value you have for "ip" in your comment? What happens if you simply copy the "ip" you use to a browser? Does it work?

Hi @kolsrud ,

Yes the domain variable is the IP Address, if i copy and paste it on the browser it gaves me error 404 (or it can't connect), it's strange because on other servers that has qlik it connects me directly on the hub.

To Turn around that problem we create another virtual proxy that use a Form.

Yesterday i see this article:
https://community.qlik.com/t5/App-Development/Qlik-Rest-APIs-gives-http-400-header-request-error-after/td-p/1668768

Do you think is related? Because the version of Qlik Sense is the November 2019 Patch 5

Thanks,
Victor

@kolsrud
Copy link
Owner

kolsrud commented Mar 8, 2022

Are you sure the virtual proxy is correctly linked to a proxy? That's the first thing I would check if I were you:

https://help.qlik.com/en-US/sense-admin/February2022/Subsystems/DeployAdministerQSE/Content/Sense_DeployAdminister/QSEoW/Administer_QSEoW/Managing_QSEoW/link-virtual-proxy-to-proxy.htm

If it is, then updating the white-list is probably a good second thing to try.

@victorvelasquez96
Copy link
Author

victorvelasquez96 commented Mar 8, 2022

Are you sure the virtual proxy is correctly linked to a proxy? That's the first thing I would check if I were you:

https://help.qlik.com/en-US/sense-admin/February2022/Subsystems/DeployAdministerQSE/Content/Sense_DeployAdminister/QSEoW/Administer_QSEoW/Managing_QSEoW/link-virtual-proxy-to-proxy.htm

If it is, then updating the white-list is probably a good second thing to try.

Sorry to respond this late.

I checked the article and i confirm that i setted in the same way:
MicrosoftTeams-image (3)

I put the hostname in the whitelist too:

x

Now it returns two type of response:
The first is when i connect only with the IP and not the prefix : 401 unauthorized

The second one is when i use "IP/connect" (it uses the NTLM to log like the Main ,Central):

xx

it's like the same but this time without the 400 Error

@kolsrud
Copy link
Owner

kolsrud commented Mar 9, 2022

Are you able to access your "connect" virtual proxy in a browser? I would suggest you focus on that first. If it doesn't work, then I would suggest you contact Qlik support to help you out with the configuration.

It could potentially be a firewall blocking your requests. In my experience a firewall will block the connection all together so that you simply get no response, but I did a quick search and it seems that there are cases where a firewall will trigger a 400 error. If you have access to the server, then you could try to run your program directly there. If that works, then there's certainly some for of server configuration you need to do to get it working.

@victorvelasquez96
Copy link
Author

victorvelasquez96 commented Mar 10, 2022

Are you able to access your "connect" virtual proxy in a browser? I would suggest you focus on that first. If it doesn't work, then I would suggest you contact Qlik support to help you out with the configuration.

It could potentially be a firewall blocking your requests. In my experience a firewall will block the connection all together so that you simply get no response, but I did a quick search and it seems that there are cases where a firewall will trigger a 400 error. If you have access to the server, then you could try to run your program directly there. If that works, then there's certainly some for of server configuration you need to do to get it working.

Hi @kolsrud ,
yes i can connect using the virtural proxy.

Somehow i resolved the problem by using the ip address instead of the domain (ex. https://ipadress instead of https://namearea.domain.com), another thing was that i insert in the domain field on the network credentials an "/" because sometimes i used "./" in my local machine.

Sorry if i disturbed you.

Thanks,
Victor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants