我想上传文件作为附件,在确切的在线文档。
以下SQL已用于创建文档:
insert into exactonlinerest..documents
( salesinvoicenumber
, type
, subject
, account
)
select 16700001
, 10
, 'subject 3'
, id
from Accounts
where code like '%24274514'
这将创建一个与精确的销售发票16700001相关的文档,并将其与帐户(客户) 24274514相关联。
当我通过精确在线的REST执行以下insert语句时:
insert into exactonlinerest..DocumentAttachments
( attachment
, document
, filename
)
select attachment
, 'ea2d9221-31b0-4217-a82f-f29c5d517b41'
, filename
from exactonlinerest..documentattachments
where filename like 'Loonstrook%'
我收到一个错误:
itgenoda001: Verplicht: Bijlage (https://start.exactonline.nl/api/v1/102673/documents/DocumentAttachments)
如何将这些包含在网上的现有薪资单作为新文档的附件上载?
PS。GUID ea2d9221...
是通过在插入文档后查询文档来发现的。
发布于 2016-12-09 17:49:15
REST表documentattachments
的documentattachments
列在检索时总是为null。
可以使用伪列attachmentfromurl
,如下所示:
insert into exactonlinerest..DocumentAttachments
( attachment
, document
, filename
)
select attachmentfromurl
, 'ea2d9221-31b0-4217-a82f-f29c5d517b41'
, filename
from exactonlinerest..documentattachments
where filename like 'Loonstrook%'
attachmentfromurl
列不能被Invantive SQL的http_get表函数或类似的普通OAuth2函数替换,因为OAuth2令牌不会自动添加到OAuth2请求中,因为确切地使用了如下所示的URL:
当文档附件来自精确的自身时。
对于诸如http://www.cnn.com这样的外部源,这是可行的。
结果:
编辑:
还可以使用以下查询从文件系统上载文件:
insert into exactonlinerest..DocumentAttachments
( attachment
, document
, filename
)
select file_contents
, dct.some_guid
, file_path
from ( select min(id) some_guid from exactonlinerest..documents ) dct
join files('c:\windows\system32', '*.png', false)@os
join read_file(file_path)@os
union all
select file_contents
, dct.some_guid
, file_path
from ( select min(id) some_guid from exactonlinerest..documents ) dct
join files('c:\windows\system32', '*.exe', false)@os
join read_file(file_path)@os
请注意,每个文件似乎有22 MB的限制。
https://stackoverflow.com/questions/41066079
复制相似问题