Hello, i've successfully created a small webapi used to communicate from a PB client application and exchange data to a remote asa database. The PB (2019R2) client app is using restclient to send and get data from a table and everything working great.
Next step i would like to send a small image grabbed from an inkpicture control to the webapi and save it to a long binary table field.
I was able to convert the blob coming from ink control to a base64 string and sent it to the web api using a sendpostrequest.
I'm not yet very familiar with C# so now my question is: is it possible to convert back the base64 string to a blob and save it to remote table?
i guess i should use PbBlob class and SqlUpdateBuilder to construct the statement and execute it from the web api but i am not sure how to do it, if it is the best choice or if is there a better approach to accomplish this task
any help or suggestion would be appreciated
tia,
simone
Any chance you could share your PB code that calls sendpostrequest as well as your controller and service code in SnapDevelop? I have a similar situation with a project involving sending large binary files to the middle tier for processing.
Hi Thomas, it's quite simple and here it is:
//converting the source ink blob into base64 string
string img
lnv_CoderObject = Create CoderObject
img= lnv_CoderObject.Base64Encode(lblb_ink)
destroy lnv_CoderObject
//calling web api passing the base64 string which execute the code i posted above
RESTClient inv_RestClient
inv_RestClient = CREATE RESTClient
inv_RESTClient.SetRequestHeader ("Content-Type", "application/json;charset=UTF-8")
inv_RestClient.Setrequestheader( "Accept-Encoding", "gzip")
string ls_id
ls_id = string(dw_1.getitemnumber( dw_1.getrow(), "id_interventi"))
inv_RestClient.setrequestheader( "id_interventi", ls_id)
ll_rtn = inv_RestClient.sendpostrequest(ls_Request_Url, img, ls_response)
if inv_RestClient.GetResponseStatusCode() <> 200 then
ls_msg = "Status Code: " + String(inv_RestClient.GetResponseStatusCode()) + '~r~n' + "Status Text: " + String(inv_RestClient.GetResponseStatusText()) + '~r~n'
Messagebox("Error - Response Info", ls_msg, stopsign!, ok!)
end if