Access 2003 i need to upload a pdf to a web api. I have coded the upload but it is se
- or -
Post a project like this$$
- Posted:
- Proposals: 2
- Remote
- #915637
- Expired
Description
Experience Level: Intermediate
General information for the business: it support
Description of requirements/functionality: We need a function to upload a pdf to a web app see code below.
We have a file being created but without content of pdf file we wanted to send
OS requirements: Windows
Extra notes: General information for the business: it support
Description of requirements/functionality: We have an access database at a clients.
The are starting to use an online app mymobileworkers
we have written the code to send a json with job details and that works
we need to code to be able to upload a pdf drawing to some jobs
we want it to be triggered by a button on the access form. we are holding the file name in a field
we have got so far and a file is created on the web app but with no content.
we have tried application/pdf and application/octet-stream but same result
help coding this needed.
Regards
kevin Doona
Specific technologies required: access 2003 vba
OS requirements: Windows
Extra notes: XMLHTTP.Open "POST", "http://live.mymobileworkers.com:8080/api/1/jobs/job/attachments/attachment", False
' xmlhttp.setRequestHeader "Content-Type", "application/json"
Dim strBody As String
Dim strFile As String
Dim aPostBody() As Byte
Dim filetosend As String
Dim boundFooter As String
'new jkd
Dim FileName As String
FileName = Me.Drawing
Dim FileContents() As Byte, FileNumber As Integer
ReDim FileContents(FileLen(FileName) - 1)
FileNumber = FreeFile
Open FileName For Binary As FileNumber
Get FileNumber, , FileContents
Close FileNumber
Dim sPostData As String
sPostData = StrConv(FileContents, vbUnicode)
'new end jkd
getFile = strFile
' xmlhttp.Open "POST", "http://uat.mymobileworkers.com:8080/api/1/jobs/job/attachments/attachment", False
filetosend = "drawing.pdf"
bound = "AaB03x"
boundSeparator = "--" & bound & vbCrLf
boundFooter = "--" & bound & "--" & vbCrLf
XMLHTTP.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & bound
strBody = boundSeparator
strBody = strBody & "Content-Disposition: form-data; name=" & """api_key""" & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "6p3gQx4AaYF8m0CJrtPZ" & vbCrLf
strBody = strBody & "--" & bound & vbCrLf
strBody = strBody & "Content-Disposition: form-data; name=""" & "job_number""" & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & Me.JobID & vbCrLf & "--" & bound & vbCrLf
strFile = filetosend
strBody = strBody & "Content-Disposition: form-data; name=" & """file"""
strBody = strBody & ";"
strBody = strBody & "filename="""
strBody = strBody & filetosend & """"
strBody = strBody & vbCrLf
strBody = strBody & "Content-Type: application/pdf" & vbCrLf & vbCrLf
strBody = strBody & sPostData
strBody = strBody & vbCrLf & "--" & bound
strBody = strBody & boundFooter
'convert to byte array
aPostBody = StrConv(strBody, vbFromUnicode)
MsgBox strBody
XMLHTTP.send (strBody)
' aPostBody
UploadXML = XMLHTTP.responseText
Set xmlHttpReq = Nothing
MsgBox XMLHTTP.responseText
Description of requirements/functionality: We need a function to upload a pdf to a web app see code below.
We have a file being created but without content of pdf file we wanted to send
OS requirements: Windows
Extra notes: General information for the business: it support
Description of requirements/functionality: We have an access database at a clients.
The are starting to use an online app mymobileworkers
we have written the code to send a json with job details and that works
we need to code to be able to upload a pdf drawing to some jobs
we want it to be triggered by a button on the access form. we are holding the file name in a field
we have got so far and a file is created on the web app but with no content.
we have tried application/pdf and application/octet-stream but same result
help coding this needed.
Regards
kevin Doona
Specific technologies required: access 2003 vba
OS requirements: Windows
Extra notes: XMLHTTP.Open "POST", "http://live.mymobileworkers.com:8080/api/1/jobs/job/attachments/attachment", False
' xmlhttp.setRequestHeader "Content-Type", "application/json"
Dim strBody As String
Dim strFile As String
Dim aPostBody() As Byte
Dim filetosend As String
Dim boundFooter As String
'new jkd
Dim FileName As String
FileName = Me.Drawing
Dim FileContents() As Byte, FileNumber As Integer
ReDim FileContents(FileLen(FileName) - 1)
FileNumber = FreeFile
Open FileName For Binary As FileNumber
Get FileNumber, , FileContents
Close FileNumber
Dim sPostData As String
sPostData = StrConv(FileContents, vbUnicode)
'new end jkd
getFile = strFile
' xmlhttp.Open "POST", "http://uat.mymobileworkers.com:8080/api/1/jobs/job/attachments/attachment", False
filetosend = "drawing.pdf"
bound = "AaB03x"
boundSeparator = "--" & bound & vbCrLf
boundFooter = "--" & bound & "--" & vbCrLf
XMLHTTP.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & bound
strBody = boundSeparator
strBody = strBody & "Content-Disposition: form-data; name=" & """api_key""" & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "6p3gQx4AaYF8m0CJrtPZ" & vbCrLf
strBody = strBody & "--" & bound & vbCrLf
strBody = strBody & "Content-Disposition: form-data; name=""" & "job_number""" & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & Me.JobID & vbCrLf & "--" & bound & vbCrLf
strFile = filetosend
strBody = strBody & "Content-Disposition: form-data; name=" & """file"""
strBody = strBody & ";"
strBody = strBody & "filename="""
strBody = strBody & filetosend & """"
strBody = strBody & vbCrLf
strBody = strBody & "Content-Type: application/pdf" & vbCrLf & vbCrLf
strBody = strBody & sPostData
strBody = strBody & vbCrLf & "--" & bound
strBody = strBody & boundFooter
'convert to byte array
aPostBody = StrConv(strBody, vbFromUnicode)
MsgBox strBody
XMLHTTP.send (strBody)
' aPostBody
UploadXML = XMLHTTP.responseText
Set xmlHttpReq = Nothing
MsgBox XMLHTTP.responseText
Kevin D.
0% (0)Projects Completed
-
Freelancers worked with
-
Projects awarded
0%
Last project
26 Apr 2024
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies