Share via

We are receiving 12156 error while making Api call from winhttp library

Lakshmana Kornu 1 Reputation point
2024-01-19T07:05:47.3666667+00:00

One of our customer receiving 12156 while making Api call from our application using proxy. But same Api call working well from PowerShell invoke-restmethod at customer and from same machine while using proxy. Our application is using WinHttp cpp methods to make http call. Some code samples as below.

HINTERNET hReq = WinHttpOpenRequest(
		hConn,
		method.c_str(),
		path.c_str(),
		NULL,		// Should default to 1.1
		WINHTTP_NO_REFERER,
		WINHTTP_DEFAULT_ACCEPT_TYPES,
		flags);
WinHttpSetOption(hReq,
				WINHTTP_OPTION_PROXY,
				&ProxyInfo,
				cbProxyInfoSize)

customer proxy info type is WINHTTP_ACCESS_TYPE_NAMED_PROXY. Customer received 12156 error as below Trying to receive HTTP Response Failure in receiving HTTP Response, error: 12156 Trying to retrieve HTTP Query Headers Failure in retrieving HTTP Query Headers, error: 12019 We tried different options to reproduce 12156 error but not able to reproduce. Only one way we were able to reproduce at our end setting max redirects < Original Api redirects like below.

DWORD maxRedirects = 0;
	if (!WinHttpSetOption(hReq_noproxy,
		WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS,
		&maxRedirects,
		sizeof(maxRedirects)))
	{


Default max redirects value is 10 (Not changed in our application). And our Api using only 1 redirect. Could you please suggest is there any other cases can we get 12156 while using proxy through WinHttp library.

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.