I keep getting this error when trying to use the API InsertPicture call,:
Unable to translate bytes [FF] at index 0 from specified code page to Unicode.
I pull the binary image data directly from a http request and then make it the body of the insert (PUT) request and can not get past this error.
here is the example vb.net code:
Public Shared Function GetDobaImageDataBinary(ByVal imgUrl As String) As Byte()
Dim request As HttpWebRequest = WebRequest.Create(imgUrl)
Dim response As HttpWebResponse = request.GetResponse()
Dim imageStream As Stream = response.GetResponseStream()
Dim memoryStream = New MemoryStream()
imageStream.CopyTo(memoryStream)
Return memoryStream.ToArray
End Function
Dim imageByteArray As Byte() = GetDobaImageDataBinary(imgUrl)
'create request object
Dim apiCallURL = "(my store url)/api-backend/Picture/InsertPicture?" & "mimeType=" & HttpContext.Current.Server.UrlEncode(mimeType) & "&seoFilename=productimage&isNew=true&validateBinary=true"
Dim httpWebRequest As HttpWebRequest
httpWebRequest = WebRequest.Create(apiCallURL)
httpWebRequest.ContentType = "application/json-patch+json"
httpWebRequest.Method = "PUT"
httpWebRequest.Accept = "application/json"
httpWebRequest.Headers("Authorization") = authorizationToken
'set the content of the request
Dim imageStream As Stream = httpWebRequest.GetRequestStream()
imageStream.Write(imageByteArray, 0, imageByteArray.Length)
imageStream.Close()
Any help would be appreciated, thanks!