Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Øystein_Kolsrud
Employee
Employee

How to Upload app using C# System.Net.WebClient

I'm trying to programmatically upload an app using the WebClient Class (System.Net), but for some reason I get the error "Could not create SSL/TLS secure channel." for that particular call. I have no problem doing a call to UploadString to for instance start a reload so I know I am able to connect and perform posts correctly, but for some reason that post with the app in the body fails. Does anyone have any idea what might be wrong?

To summarize, this method works:

public string Post(string endpoint, string body)

{

    return UploadString(new Uri(Uri, endpoint), body);

}

But this fails:

public byte[] Post(string endpoint, byte[] body)

{

    return UploadData(new Uri(Uri, endpoint), body);

}

I've been experimenting a lot with different header settings for the resulting request, but haven't been able to make it work. And I'm rather confused that it complains about that SSL/TLS channel problem and don't see how the two calls differs with respect to that.

1 Solution

Accepted Solutions
Øystein_Kolsrud
Employee
Employee
Author

I had done a mistake in configuring the query parameters. Apparently, one has to remove any preexisting '?' from the query when appending a new query to a UriBuilder.Query property. So I basically had to do a Substring(1) on the query like they describe here:

UriBuilder.Query Property (System)

That's a pretty confusing error message and a pretty weird property...

View solution in original post

7 Replies
Øystein_Kolsrud
Employee
Employee
Author

I had done a mistake in configuring the query parameters. Apparently, one has to remove any preexisting '?' from the query when appending a new query to a UriBuilder.Query property. So I basically had to do a Substring(1) on the query like they describe here:

UriBuilder.Query Property (System)

That's a pretty confusing error message and a pretty weird property...

adam_westhusing
Contributor II
Contributor II

I'm actually trying to utilize the RestClient you wrote and I'm running into this same error ("Could not create SSL/TLS secure channel.") uploading apps.  I don't have this problem uploading extensions.

Is it a fair conclusion it must be the endpoint that is not set correctly?  I don't have this issue with any other endpoint, just the upload app one.

Here's my endpoint:

string uploadAppEndpoint = "/qrs/app/upload?name=" + Uri.EscapeDataString(System.IO.Path.GetFileName(filename));

Øystein_Kolsrud
Employee
Employee
Author

I just realized I hadn't pushed the fix to github. Have a look at it now and see if the problem persists!

https://github.com/kolsrud/qlik_rest_sdk

adam_westhusing
Contributor II
Contributor II

No, same problem.  I had already used your workaround for the UriBuilder Query.

Any other ideas on what could be going on?  Have you had luck uploading apps?

Øystein_Kolsrud
Employee
Employee
Author

One problem I ran into was that I had to modify the ContentType of the web request. I've pushed some changes that makes it possible to configure the requests, and I've added a new example that illustrates how to use it to upload an app. That works for me at least, but I didn't see the exact same message you are so it could be something else you are running into.

Anyway, check out this example:

https://github.com/kolsrud/qlik_rest_sdk/tree/master/Qlik.Sense.RestClient/Examples/AppUpload

mostal75
Contributor III
Contributor III

Hello

I have same issue

Do you resolve it please ?

Regards

adam_westhusing
Contributor II
Contributor II

My apologies for not replying back earlier, but yko‌'s solution worked for me.  Having the content type of the web request to match the .qvd appeared to be the issue I had.  Since I adopted the ContentType fix, I've been able to upload apps to my Qlik server.

Thanks!