Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
onkellepie
Partner - Contributor III
Partner - Contributor III

QlikSense: ODAG API 500 internal server error

Hi all,

i have a small c# command line tool and want to create an ODAG Link like described here:

OdagService − post /links - Qlik | Help

But it returns 500 internal server error.

 

Virtuell Proxy is configured correctly. Normal GET Requests are working (like about or get all available Links). But POST Requests are not working.

If i exactly do the same within a ASP.Net Website with CodeBehind it works fine. 

The goal is to implement a backend-service to create ODAG Apps automatically.

 

My sample code:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Newtonsoft;
using Newtonsoft.Json;

namespace ODAG_API_Test
{
class Program
{

static void Main(string[] args)
{
Console.Clear();
Console.WriteLine("Test Create Link");
Console.Read();
SendPostRequest();

}

public static string SendPostRequest()
{
try
{

string json = "{\"id\":\"\",\"name\":\"UniqueAppName_320\",\"templateApp\":\"4f563fff-744a-4d29-80ae-a3c087baf6bd\",\"rowEstExpr\":\"1=1\",\"privileges\":[],\"properties\":{\"rowEstRange\":[{\"context\":\"*\",\"highBound\":100}],\"genAppLimit\":[{\"context\":\"User_*\",\"limit\":5}],\"appRetentionTime\":[{\"context\":\"User_*\",\"retentionTime\":\"unlimited\"}],\"publishTo\":[],\"targetSheet\":[{\"context\":\"User_*\",\"sheetId\":\"\"}]},\"tags\":[],\"selectionApp\":\"950ed3b0-2696-4337-ae94-85547b1ea9f7\"}";

Console.WriteLine("Start webRequest");
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://SERVER/odag_api_test/api/odag/v1/links?xrfkey=QVad6OMD6iTcrssc");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Headers.Add("hdr-reload", @"DOMAIN\USER");
httpWebRequest.Headers.Add("X-Qlik-xrfkey", "QVad6OMD6iTcrssc");

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(json);
}

var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
string result;
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
}

Console.WriteLine(result);

return result;
}
catch(WebException exc)
{
Console.WriteLine("ERROR");
Console.WriteLine(exc.Message);
Console.WriteLine(exc.Response);
Console.WriteLine(exc.Status);
return "ERROR";
}

}
}

}

 

Can anyone help to understand this or any hints how to solve this Problem?

There are no informations about my queries within the Qlik Logs (or i dont find them?!)

I currently on QlikSense November 2020 SR3 

Many thanks and Regards

Labels (4)
1 Solution

Accepted Solutions
onkellepie
Partner - Contributor III
Partner - Contributor III
Author

Found a solution.

For others who also have this Problem.

The Problem is, that this code is implemented in .Net Framework. I also try with .Net Core. .Net Core works perfect, but not .Net Framework.

In my case .Net Framework sends the Header "Expect: 100-continue" this works for QRS API but not for ODAG API. To disable the Header i added this line of code:

System.Net.ServicePointManager.Expect100Continue = false;

before creating the request. Now it works perfect.

 

View solution in original post

1 Reply
onkellepie
Partner - Contributor III
Partner - Contributor III
Author

Found a solution.

For others who also have this Problem.

The Problem is, that this code is implemented in .Net Framework. I also try with .Net Core. .Net Core works perfect, but not .Net Framework.

In my case .Net Framework sends the Header "Expect: 100-continue" this works for QRS API but not for ODAG API. To disable the Header i added this line of code:

System.Net.ServicePointManager.Expect100Continue = false;

before creating the request. Now it works perfect.