Archived Forum PostQuestion:
I am using the code from the (Delphi DLL) HTTP multipart/form-data Upload example (slightly modified) and get this error on the Protocol Violation Report. "Content-Length mismatch. Request Header indicated 403 bytes, but client sent 0 bytes".
Fiddler shows Content-Length: 403 Content-Type: multipart/form-data: boundary=---etc but no data in the HexView after : 403...
Any suggestions would be appreciated.
This is the code...
ckHTTP := CkHttp_Create();
ckHTTPRequest := ckHttpRequest_Create();
try
{--- any string unlocks the component for the 1st 30-days.}
blnResult := ckHTTP_UnlockComponent(CkHttp,cChilkatUnlockHTTP);
if (not blnResult) then
begin
ShowMessage (ckHTTPLastErrorText(ckHTTP));
strResponse := strResponse + ckHTTPLastErrorText(ckHTTP) + cCrLf;
Exit;
end;
CkHttpRequest_putVerboseLogging (ckHTTPRequest, true);
CkHttp_putUseIEProxy (ckHTTP, true);
CkHttpRequest_putDebugLogFilePath (ckHTTPRequest,
PChar(ExtractFilePath (Application.ExeName) + '\SessionLogFile.txt'));
CkHttpRequest_putHttpVerb (ckHTTPRequest, 'POST');
CkHTTPRequest_putContentType (ckHttpRequest, PWideChar('multipart/form-data'));
CkHTTPRequest_putCharset (ckHttpRequest, PWideChar('utf-8'));
CkHTTPRequest_putPath (ckHttpRequest, PWideChar('/restapi/1/accounts/xxxxxxxx/envelopes.xml'));
CkHttpRequest_AddHeader (ckHTTPRequest, 'Expect', '100-continue');
strXML := '<abc>This is the test.xml content</abc>';
blnResult := CkHttpRequest_AddStringForUpload
(ckHTTPRequest,
'part1',
'part1',
PWideChar(strXML),
'utf-8');
if (not blnResult) then
begin
ShowMessage (ckHTTP__LastErrorText(ckHTTP));
strResponse := strResponse + ckHTTP__LastErrorText(ckHTTP) + cCrLf;
Exit;
end;
blnResult := CkHttpRequest_AddFileForUpload (ckHTTPRequest,
'part2',
PWideChar(pstrUNCPdfFileName));
if (not blnResult) then
begin
ShowMessage (ckHTTP__LastErrorText(ckHTTP));
strResponse := strResponse + ckHTTP__LastErrorText(ckHTTP) + cCrLf;
Exit;
end;
CkHttp_putKeepEventLog(ckHTTP,true);
CkHTTPResponse := ckHTTP_SynchronousRequest(ckHTTP,
cEndpointDomain,
cEndpointPort,
cEndpointSsl,
ckHTTPRequest);
This is the log contents...
Path:
DllDate: Aug 27 2015
ChilkatVersion: 9.5.0.52
UnlockPrefix: BRIANDHttp
Username: RS2010-DEV1:DEV1
Architecture: Little Endian; 32-bit
Language: Delphi/C++ Builder XE2/XE3
VerboseLogging: 1
path: [/restapi/1/accounts/1170991/envelopes.xml]
(leaveContext 16ms)
AddHeader:
DllDate: Aug 27 2015
ChilkatVersion: 9.5.0.52
UnlockPrefix: BRIANDHttp
Username: RS2010-DEV1:DEV1
Architecture: Little Endian; 32-bit
Language: Delphi/C++ Builder XE2/XE3
VerboseLogging: 1
name: Expect
value: 100-continue
(leaveContext)
AddStringForUpload:
DllDate: Aug 27 2015
ChilkatVersion: 9.5.0.52
UnlockPrefix: BRIANDHttp
Username: RS2010-DEV1:DEV1
Architecture: Little Endian; 32-bit
Language: Delphi/C++ Builder XE2/XE3
VerboseLogging: 1
(leaveContext)
AddFileForUpload:
DllDate: Aug 27 2015
ChilkatVersion: 9.5.0.52
UnlockPrefix: BRIANDHttp
Username: RS2010-DEV1:DEV1
Architecture: Little Endian; 32-bit
Language: Delphi/C++ Builder XE2/XE3
VerboseLogging: 1
name: part2
localFilePath: C:\Delphi_2010\Temp Progs\DocuSign RestAPI Chillkat\SendToDocuSign.txt
Success.
(leaveContext 16ms)
Solved it. The problem was this line... CkHttp_putUseIEProxy (ckHTTP, true); This set the proxy to 127.0.0.1:8888. When I removed the line it all worked. Maybe there is something that need to set for the proxy, like allow HTTPS or something. I will hunt around. Would be nice if anyone has a work around for this as it would still be nice to be able to use fiddler.