Welcome Guest Search | Active Topics | Sign In | Register

running javascript submit for authentication/changing URL Options
leon
Posted: Tuesday, March 16, 2021 1:03:42 PM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 9
I have seen this code work, but it is extremely inconsistent. Works maybe 1 out of 10 times. I thought it could be a timing thing but i've stepped through the code and it is equally inconsistent. also, i am using the loadURLandwait. And switching from evalscript to queuescriptcall didn't change anything.

basically it's an authentication site. i want to fill in the fields and press the submit button in an automated fashion. I have done this manually in google chrome/developer tools with the same javascript lines and it works. And as I say, this code has worked twice out of maybe 15 tries

I don't think i'm opening a 'new window', am i? I mean if i just change the webview.url value then I assume it loads what's there, right? not clear to me after a form submission what the new URL is, but as i say what i have here has worked, as evidenced by the screenshots i have saved

Anyway i don't understand how it can work some times and not others.

Thanks for any help you may be able to give

==
Module Module1
Private m_WebView1 As New EO.WebBrowser.WebView
Dim threadrunner1 As New EO.WebBrowser.ThreadRunner()


Private Sub WebView_UrlChanged(sender As Object, e As NewWindowEventArgs)
m_WebView1.Url = e.TargetUrl

End Sub
Sub Main()
Dim theUrl As String
theUrl = "http://ulviasp00178.fg.rbc.com:8080/globalriskfilegateway/retrive"
m_WebView1 = threadrunner1.CreateWebView()


m_WebView1.LoadUrlAndWait(theUrl)
m_WebView1.Capture().Save("c:\eraseme")
Console.WriteLine(m_WebView1.Title)
Console.WriteLine(m_WebView1.Url)


m_WebView1.QueueScriptCall("document.getElementById('displayLogin_username').value='XXXX';")
m_WebView1.QueueScriptCall("document.getElementById('displayLogin_password').value='XXXXX';")
m_WebView1.QueueScriptCall("document.getElementById('domainsel').value='OAK';")
m_WebView1.QueueScriptCall("document.forms[0].elements['selectedDomain'].value = 'OAK';")

m_WebView1.Capture().Save("c:\eraseme15")

m_WebView1.QueueScriptCall("document.forms[0].action = '/globalriskfilegateway' + '/login';")
m_WebView1.QueueScriptCall("document.forms[0].submit();")
'm_WebView1.EvalScript("validateAndSubmit()")

theUrl = "http://ulviasp00178.fg.rbc.com:8080/globalriskfilegateway/retrive.action"
m_WebView1.LoadUrlAndWait(theUrl)

m_WebView1.Capture().Save("c:\eraseme2")

m_WebView1.QueueScriptCall("document.forms[0].action = '/globalriskfilegateway' + '/upload';")
m_WebView1.QueueScriptCall("document.forms[0].submit();")
theUrl = "http://ulviasp00178.fg.rbc.com:8080/globalriskfilegateway/upload"
m_WebView1.LoadUrlAndWait(theUrl)

m_WebView1.Capture().Save("c:\eraseme3")
m_WebView1.Destroy()
Stop
End Sub

End Module

eo_support
Posted: Tuesday, March 16, 2021 1:31:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

It will not work like this. The key is when you call the following code:

Code: C#
m_WebView1.QueueScriptCall("document.forms[0].submit();")


The submit action does NOT happen right away. It is being queued in the background and then being carried out asynchronously. Once the submit is carried out, the server will send a response back and the WebView will then automatically load that page (or in case the server sends back a redirect to a new Url and then the WebView will proceed to load the new Url). Only till then the submit cycle ends.

This process seems simple enough and it usually happens in a split seconds. It is very easy for a human to decide whether this process has been completed successfully or not but it is not so easy for code in the above manner because you have no way to explicitly track the HTTP request resulted from your submit call. The easiest way for you to increase the "odd" of your code succeeding is to wait for a short period after you call submit so that you won't be starting to load a separate page before the submit actually happen.

The recommend method to handle such case is to use webView.LoadRequest. You simply fill the Request object with necessary information (such as user name and password) and then use webView.LoadRequestAndWait(request) and that will wait until the cycle ends. This would work reliability because you would be explicitly track the request object.

Hope this helps.

Thanks!

leon
Posted: Tuesday, March 16, 2021 3:09:26 PM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 9
Thanks for quick reply - for now I think I figured out what I needed to
eo_support
Posted: Tuesday, March 16, 2021 3:54:52 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Great!
leon
Posted: Thursday, March 18, 2021 2:06:00 PM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 9
Hello again -

You helped me bigtime last time so I want to ask one more question.

I have successfully logged in, which I can see because I am saving a screenshot of where it ends up. So thanks for that assistance. The next part involves loading a file onto their server.

Below is the javascript on the page. I realize you can't do full tech support for everyone's problems, but if you have any hints about eowebbrowser functions to use, like u did last time, that would save me an enormous amount of time

I'm guessing the upload itself ought to be done by a function similar to what you suggested for the login last time?

Thanks in advance

Leon

=
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="StyleSheet" href="/globalriskfilegateway/css/main.css" type="text/css">
<title>Global Risk File Manager</title>
<script type="text/javascript" src="/globalriskfilegateway/scripts/tree.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/globalriskfilegateway/uploadify/jquery.uploadify-3.1.min.js"></script>

<script type="text/javascript">

function fileupload() {

if(document.forms[0].elements['uploadFileType'].value== '-1')
{
alert('Please select type of file to be uploaded');
return false;
}


if(document.forms[0].elements['subFolder'].value== '-1')
{
alert('Please select Logical Date ');
return false;
}

if (document.forms[0].elements['commentary'].value.length == 0) {
alert('Commentary should not be left blank');
return false;
}


document.forms[0].action = "/globalriskfilegateway" + "/fileUpload";
document.forms[0].submit();
}

function filehtml5upload(){

if(document.forms[0].elements['uploadFileType'].value== '-1')
{
alert('Please select type of file to be uploaded');
return false;
}


if(document.forms[0].elements['subFolder'].value== '-1')
{
alert('Please select Logical Date ');
return false;
}

if (document.forms[0].elements['commentary'].value.length == 0) {
alert('Commentary should not be left blank');
return false;
}



document.forms[0].action = "/globalriskfilegateway" + "/fileHtmlUpload";
document.forms[0].submit();
}
function cancel() {
document.forms[0].action = "/globalriskfilegateway" + "/retrive";
document.forms[0].submit();
}

function statusDetailsPopup(id)
{

var action = "/globalriskfilegateway" + "/statusDetails?statusdetails=" + id;
window.open(action, "", "resizable=yes,scrollbars=yes,width=400,height=360,top=220,left=200");
}
function statusDetailsPopupEolus(id,logicDate){

var action = "/globalriskfilegateway" + "/statusDetailsElous?statusdetails=" + id + "&logicDate=" + logicDate;
window.open(action, "", "resizable=yes,scrollbars=yes,width=400,height=360,top=220,left=200");

}

function selectType(){

if(document.forms[0].elements['uploadFileType'].value== '-1')
{
alert('Please select type of file to be uploaded');
return false;
}
}

function setVisibility() {
if(document.forms[0].elements['result']){
if (document.forms[0].elements['result'].value == 'error' || document.forms[0].elements['result'].value == 'warnings' ) {
document.all['errortable'].style.display = 'inline';
}
if (document.forms[0].elements['result'].value == 'success') {
document.all['successtable'].style.display = 'inline';
}
}
}

function autoPopulateDomain(targetElement) {

if (targetElement.options[targetElement.selectedIndex].value == '-1') {
return;
}
document.forms[0].elements['uploadFileType'].value = targetElement.options[targetElement.selectedIndex].value;

}

function autoPopulateFolder(targetElement) {

if (targetElement.options[targetElement.selectedIndex].value == '-1') {
return;
}
document.forms[0].elements['subFolder'].value = targetElement.options[targetElement.selectedIndex].value;

}
</script>
<script type="text/javascript">
$(function() {

$('#file_upload').uploadify(
{
'buttonImage' : '/globalriskfilegateway/images/button1.png',
'swf' : '/globalriskfilegateway/uploadify/uploadify.swf',
'uploader' : '/globalriskfilegateway/riskfilemanager/doUpload.action',
'queueID' : 'fileQueue',
'method' : 'post',
'height' : '35',
'disable' : true,
'width' : '95',
'fileTypeExts' : '*.xls;*.csv',
'onQueueComplete' : function refresh() {
document.forms[0].action = "/globalriskfilegateway" + "/fileDisplay";
document.forms[0].submit();
},
'onUploadProgress' : function dis(){
document.getElementById("loading").style.display = "block";
},
'onInit' : function (){
$('#file_upload').uploadify('enable', false);
},

'onUploadStart' : function() {
$('#file_upload').uploadify("settings", 'formData', {"subFolder" : $("#subFolder").val(),
"uploadFileType" : $("#uploadFileType").val(), "commentary" : $("#commentary").val()})
}

});
});

function browserCheck(){

var test_canvas = document.createElement("canvas");
var canvascheck=(test_canvas.getContext)? true : false ;
if(!canvascheck){
document.getElementById("html5Supp").style.display = "none";
document.getElementById("html5NotSupp").style.display = "inline";
document.getElementById("uploadNoHtml5").style.display = "inline";
document.getElementById("uploadHtml5").style.display = "none";
document.forms[0].elements['hd_htmlCol'].value = 'NO';

}else{
document.getElementById("html5Supp").style.display = "inline";
document.getElementById("html5NotSupp").style.display = "none";
document.getElementById("uploadNoHtml5").style.display = "none";
document.getElementById("uploadHtml5").style.display = "inline";
document.forms[0].elements['hd_htmlCol'].value = 'YES';
}

}




</script>
</head>
<form id="fileUpload" name="fileUpload" action="/globalriskfilegateway/fileUpload.action" method="POST" enctype="multipart/form-data">
<table class="wwFormTable">
<input type="hidden" name="hd_htmlCol" value="null">
<body onload="javascript:setVisibility();browserCheck();">
<table width="100%" border="1" cellpadding="0" cellspacing="0"
align="center">
<tr>
<td height="30" colspan="2">


<script type="text/javascript">
function switchGroup() {
var selectedVal=document.getElementById("pages").value;
var action = "/globalriskfilegateway" + "/switchGroup?selectedVal=" + selectedVal;
document.forms[0].action = action;
document.forms[0].submit();
}
</script>
<style type="text/css">

.tablehead
{
border-width: 0 0 0px 0px;
border-spacing: 0;
border-collapse: collapse;

}

</style>




<table class="tablehead" width="100%">
<tr >
<td bgcolor="#003399" width="5%" valign="top"><img src="/globalriskfilegateway/images/rbc_logo0.png" /></td>
<td bgcolor="#003399" width="18%" align="left" style="font: bold 12pt Verdana, sans-serif;color: FFFFFF">prod-RBCCM Risk File Manager</td>


<td bgcolor="#003399" width="16%" align="center" style=" font: bold 10pt Verdana, sans-serif;color: FFFFFF">EOLUS(Local Risk) </td>


<td bgcolor="#003399" width="20%" align="left" style=" font: bold 8pt Verdana, sans-serif;color: FFFFFF"> &nbsp; </td>

<td bgcolor="#003399" width="27%" align="right" style=" font: bold 8pt Verdana, sans-serif;color: FFFFFF">Welcome XXXXXX, XXXXX </td>
<td bgcolor="#003399" width="1%" align="left" style=" font: bold 8pt Verdana, sans-serif;color: FFFFFF"> | </td>

<td bgcolor="#003399" width="3%" align=left style=" font: bold 8pt Verdana, sans-serif;color: FFFFFF"><a style="color: FFFFFF" href="/globalriskfilegateway/retrive" >Home</a></td>
<td bgcolor="#003399" width="1%" align="left" style=" font: bold 8pt Verdana, sans-serif;color: FFFFFF"> | </td>
<td bgcolor="#003399" width="3%" align="left" style=" font: bold 8pt Verdana, sans-serif;color: FFFFFF"> &nbsp; </td>
<td bgcolor="#003399" width="5%" align="left" style=" font: bold 8pt Verdana, sans-serif;color: FFFFFF"><a
href="logout" style="color: FFFFFF">Sign Out</a></td>
</tr>

</table>



</td>
</tr>

<tr>
<td height="540" width="100" align="left" valign="top"></td>
<td height="450" width="500" align="left" valign="top">

<table border="0" width="800px">
<tr style=" padding-bottom: 10px " >
<td colspan="2" bgcolor="#FFFFFF" style="text-align: left; vertical-align: bottom; padding: 5pt; font: 9pt Verdana, sans-serif; color: #000000">Please select a file of .csv type to upload</td>
</tr>


<tr>
<td class="tdLabel" align="right"><label for="type" class="label">Select type:</label></td>
<td align="left"><select style="width: 138px; padding:1px; margin:2px" id="uploadFileType" name="uploadFileType"
onchange="autoPopulateDomain(this);">




<option selected="selected" value="Addons">Addons</option>





</select>
</td>
</tr>



<tr>
<td class="tdLabel" align="right"><label for="type" class="label">Select Logical Date:</label></td>
<td align="left">
<select
style="width: 138px; padding: 1px; margin: 2px" id="subFolder"
name="subFolder" onchange="autoPopulateFolder(this);">


<option value="T-1">T-1</option>



<option value="AFS Config files">AFS Config files</option>
</select>
</td>
<td></td> <td></td> <td></td> <td></td>
<td>
<span style="background: #F0F0F0; width: 225px; font: bold 8pt Verdana, sans-serif; text-align: center; cursor: pointer; color: #000000; margin: 2px; padding: 1px;">
EOLUS:<br/>
T-1 business date = 2021-03-15 <br/>
T-2 business date = 2021-03-12
</span>
</td>
</tr>
<tr>
<td class="tdLabel"><label for="commentary" class="label">Commentary:</label></td>
<td
class="tdInput"
><textarea name="commentary" cols="25" rows="5" id="commentary"></textarea></td>
</tr>




<tr>
<td id="html5NotSupp" align="center" valign="baseline" colspan="2" ><input type="file" name="Filedata" id="file_upload" />
</td>

<td valign="baseline" align="center" >
<tr>
<td class="tdLabel"></td>
<td
class="tdInput"
><input type="file" name="fileUploadRfm" id="html5Supp" multiple="multiple"/></td>
</tr>


</td>
</tr><tr></tr>

<tr>
<td align="right" colspan="6">
<input id="uploadNoHtml5"
style="background: #F0F0F0; width: 80px; font: bold 8pt Verdana, sans-serif; text-align: center; cursor: pointer; color: #000000; margin: 2px; padding: 1px;"
type="button" value="Upload" onclick="javascript:fileupload();">


<input id="uploadHtml5"
style="background: #F0F0F0; width: 80px; font: bold 8pt Verdana, sans-serif; text-align: center; cursor: pointer; color: #000000; margin: 2px; padding: 1px;"
type="button" value="Upload" onclick="javascript:filehtml5upload();"></td>
<td>
<input
style="background: #F0F0F0; width: 90px; font: bold 8pt Verdana, sans-serif; text-align: center; cursor: pointer; color: #000000; margin: 2px; padding: 1px;"
type="button" value="Back" onclick="javascript:cancel();">
</td>
</tr>


</td>
</tr>
</table>
<div id='loading' style='display: none'>
<table>
<tr>
<td padding: 5pt; font: 9ptVerdana, sans-serif; color: #000000">
<img src="/globalriskfilegateway/images/ajax-loader.gif" /> Loading
Files.............
<td>
</tr>
</table>
</div>
<table width="950px" border="1" class="resulttable" >
<tr>
<td bgcolor="#808080"
style="text-align: left; vertical-align: bottom; padding: 5pt; font: 8pt Verdana, sans-serif; color: #FFFFFF">
<B>SNo</B>
</td>
<td bgcolor="#808080"
style="text-align: left; vertical-align: bottom; padding: 5pt; font: 8pt Verdana, sans-serif; color: #FFFFFF">
<B>FileName</B>
</td>
<td bgcolor="#808080"
style="text-align: left; vertical-align: bottom; padding: 5pt; font: 8pt Verdana, sans-serif; color: #FFFFFF">
<B>Type</B>
</td>
<td bgcolor="#808080"
style="text-align: left; vertical-align: bottom; padding: 5pt; font: 8pt Verdana, sans-serif; color: #FFFFFF">
<B>Status</B>
</td>
<td bgcolor="#808080"
style="text-align: left; vertical-align: bottom; padding: 5pt; font: 8pt Verdana, sans-serif; color: #FFFFFF">
<B>Description</B>
</td>

<td bgcolor="#808080"
style="text-align: left; vertical-align: bottom; padding: 5pt; font: 8pt Verdana, sans-serif; color: #FFFFFF">
<B>Business Date</B>
</td>
<td bgcolor="#808080"
style="text-align: left; vertical-align: bottom; padding: 5pt; font: 8pt Verdana, sans-serif; color: #FFFFFF">
<B>Logical Date</B>
</td>

</tr>


</table>

</td>
</tr>
</table>
</body>

</table></form>




</html>
eo_support
Posted: Thursday, March 18, 2021 8:14:48 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

You are probably approaching this from the wrong direction ---- you can't keep thinking about automating a web site like this through JavaScript. Particularly about file upload, the browser engine has numerous checks to make sure you DO NOT automate it through JavaScript. The reason is very simple, if such checks didn't exist, people would be able to just write pages to automatically fetch sensitive file on the end user's computer to their server. So if you want it to work reliability, you need to take the script part out and call LoadRequest directly.

If you still want to press ahead with JavaScript automation, you can try to use the built-in debugger to find out what went wrong for you:

https://www.essentialobjects.com/doc/webbrowser/advanced/debug.aspx

Thanks!
leon
Posted: Thursday, March 18, 2021 10:12:30 PM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 9
I apologize - I wasn't too clear what i meant. What i copy/pasted just now was the contents of the html file of the page I am trying to automate. I have no need to use javascript - I'm happy to use LoadRequest. I guess you are saying that I should use that, same as I did in the last part.

And just like last time, before calling LoadRequestAndWait i do series of request1.postdata.addvalue commands, yes? What is confusing to me is what exactly i put in those postdata.addvalue commands. Not knowing javascript I am unsure what it is expecting. I do see where it needs a "Commentary" field and I can do that part, at least. But does it need a string representing the file location and filename? ? I mean the process there seems to have two parts, one where you choose the file to upload, and another where you press the upload button. Not clear to me how it works

Thanks again for any ideas you may have

Leon
eo_support
Posted: Friday, March 19, 2021 7:59:38 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

To upload a file, you will need to use request.PostData.Add to add three PostDataItem: The first and the third one contains raw binary data and the the second one contains the file name path. The raw binary data is the "multi-part boundary" that you must generate yourself which serves as the boundary of your file item (because the same request would contain other form fields value as well). The request's ContentType must be set to "multipart/form-data". See here for more details:

https://www.essentialobjects.com/doc/eo.webbrowser.postdataitemconstructor1.aspx

Because this is a multi-part request, you will need to manually encode all other variables as well. Once they are encoded, you can put them in another raw PostDataItem (so together you will have 4). You can search online for more information about multi-part format.

To debug your code, you can use a traffic monitor such as Fiddler to inspect the contents of the request being sent to the server. You can then compare this content with the correct content being sent from a regular browser so that you can find and fix the missing/incorrect part.

Thanks!
leon
Posted: Friday, March 19, 2021 4:25:57 PM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 9
ok, as always i very much appreciate the quick and helpful response. Let me try what you recommend and see how far i get
leon
Posted: Wednesday, May 5, 2021 10:48:33 AM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 9
Well, I feel I am getting closer, but still having trouble. I got Fiddler to work and I can see that the prior posts I do are working. I'm on the final screen where I actually upload the file.

Here is what I see Fiddler reporting when I do it manually:

------WebKitFormBoundaryWWoZrkZqocuJFe0E
Content-Disposition: form-data; name="hd_htmlCol"

YES
------WebKitFormBoundaryWWoZrkZqocuJFe0E
Content-Disposition: form-data; name="uploadFileType"

Addons
------WebKitFormBoundaryWWoZrkZqocuJFe0E
Content-Disposition: form-data; name="subFolder"

T-1
------WebKitFormBoundaryWWoZrkZqocuJFe0E
Content-Disposition: form-data; name="commentary"

ZQG0
------WebKitFormBoundaryWWoZrkZqocuJFe0E
Content-Disposition: form-data; name="Filedata"; filename=""
Content-Type: application/octet-stream


------WebKitFormBoundaryWWoZrkZqocuJFe0E
Content-Disposition: form-data; name="fileUploadRfm"; filename="ION_add_ons_IPS.csv"
Content-Type: application/vnd.ms-excel

[leon: then it shows the content of the file, followed by this:]

------WebKitFormBoundaryWWoZrkZqocuJFe0E--

===

When I run my code i see that fiddler isn't reporting any attempt to post anything. Not sure why that is. It's also unclear to me how I should (or if i need to?) convert my initial postdata.addvalue's into postdata items(?). Here's the code for that final section

theurl4 = "[site name]"
Dim request4 As New Request(theurl4)

' request4.PostData(New PostDataItem(New Byte[5]))
request4.PostData.AddValue("hd_htmlCol", "YES")
request4.PostData.AddValue("uploadFileType", "Addons")
request4.PostData.AddValue("subFolder", "T-1")
request4.PostData.AddValue("commentary", "ZQG0")
request4.PostData.Add(New PostDataItem(System.Text.Encoding.Unicode.GetBytes("------WebKitFormBoundarynY0rdgnSAnIf728R")))
request4.PostData.Add(New PostDataItem("[file location]"))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.Unicode.GetBytes("------WebKitFormBoundarynY0rdgnSAnIf728R")))
request4.ContentType = "multipart/form-data"

request4.Method = "POST"

m_WebView1.LoadRequestAndWait(request4)
===

Thanks for any advice to resolve this final piece of the puzzle
eo_support
Posted: Thursday, May 6, 2021 1:10:27 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

You should not use PostData.AddValue and Add at the same time. You should exclusively use Add(New PostDataItem(...)) in your case. You must also make sure that your m_WebView1 has been initialized.

Thanks!
leon
Posted: Friday, May 7, 2021 9:52:31 AM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 9
oh ok. i think i got the idea of mixing them from this, but maybe it doesn't apply to my case?

https://www.essentialobjects.com/forum/postst9464_EOWebBrowser-POST-LoadRequest-with-raw-POST-data.aspx

Anyway - somehow apparently i must convert my 'addvalue' pairs to raw data? How do I do that? And then I don't understand how the boundary constant gets inserted in between each item, the way it appears in my last post when fiddler reported what it did manually.

Thanks
eo_support
Posted: Friday, May 7, 2021 1:36:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
leon wrote:
And then I don't understand how the boundary constant gets inserted in between each item, the way it appears in my last post when fiddler reported what it did manually.


This is the key --- you need to understand how these boundaries are generated and formed in order to do this correctly. We are not in a position to explain details of specific Web standard/technology to you. You will need to search online yourself for this. We are only trying to point you to the right direction here.
leon
Posted: Tuesday, June 8, 2021 9:03:58 AM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 9
I did finally get this working - and used Fiddler to ensure it matched the manual method. Thanks for your help.

I just want to show you my code that did successfully upload the file, and ask if in future I have to do something like this, whether your software can make this any simpler? I mean in the end I am spelling out every piece of data going in. i even read in my file and send the array of bytes. I had hoped eowebbrowser would somehow handle the multipart for me, without my needing to do it in such a spelled-out way. The link I referenced above -

https://www.essentialobjects.com/forum/postst9464_EOWebBrowser-POST-LoadRequest-with-raw-POST-data.aspx

- seemed to suggest at least I could mix addvalue's and add's together, but I guess you are saying one cannot?

Anyway any advice for future projects would be most welcome

Thanks again. Here is the code I used that did work

===

theurl4 = "<web address>"

Dim request4 As New Request(theurl4)

Dim strBoundary As String
strBoundary = "----WebKitFormBoundarynY0rdgnSAnIf728R"
request4.ContentType = "multipart/form-data; boundary=" & strBoundary
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("--" & strBoundary & vbCrLf)))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("Content-Disposition: form-data; name=""hd_htmlCol""" & vbCrLf & vbCrLf & "YES" & vbCrLf)))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("--" & strBoundary & vbCrLf)))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("Content-Disposition: form-data; name=""uploadFileType""" & vbCrLf & vbCrLf & "Addons" & vbCrLf)))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("--" & strBoundary & vbCrLf)))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("Content-Disposition: form-data; name=""subFolder""" & vbCrLf & vbCrLf & "T-1" & vbCrLf)))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("--" & strBoundary & vbCrLf)))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("Content-Disposition: form-data; name=""commentary""" & vbCrLf & vbCrLf & "ZQG0" & vbCrLf)))

request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("--" & strBoundary & vbCrLf)))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("Content-Disposition: form-data; name=""Filedata""; filename=""""" & vbCrLf & "Content-Type: application/octet-stream" & vbCrLf & vbCrLf & vbCrLf)))

request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("--" & strBoundary & vbCrLf)))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes("Content-Disposition: form-data; name=""fileUploadRfm""; filename=""ION_add_ons_IPS.csv""" & vbCrLf & "Content-Type: application/vnd.ms-excel" & vbCrLf & vbCrLf)))

Dim buff(200000) As Byte
buff = File.ReadAllBytes("<file location>")

request4.PostData.Add(New PostDataItem(buff))
request4.PostData.Add(New PostDataItem(System.Text.Encoding.UTF8.GetBytes(vbCrLf & "--" & strBoundary & "--")))
request4.Method = "POST"

m_WebView1.LoadRequestAndWait(request4)
eo_support
Posted: Tuesday, June 8, 2021 10:05:41 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Thanks for sharing. Yes. We understand it would be nice to have this directly supported by our component. The browser engine already have code that does this on the browser engine side. However that code path is only used when user select a file interactively. We will look into it and see whether we can expose that part so that you will be able to invoke it programmatically.
leon
Posted: Tuesday, June 8, 2021 10:08:13 AM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 9
ok great, thanks for your reply


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.