Web API (backend) - InsertPicture failing : Unable to translate bytes [FF] at index 0 from specified code page to Unicode.

9 个月 前
Unfortunately for the mobile application, the new version of the WEB API plugin will be released only together with the new version of the application itself, since the mobile application is built to work with a specific version of the API.
9 个月 前
twinvision wrote:
How do we get the updated web API package if we got it in the mobile app bundle? I do not see an updated mobile app bundle to download.

Please check your email
9 个月 前
a.m. wrote:
How do we get the updated web API package if we got it in the mobile app bundle? I do not see an updated mobile app bundle to download.
Please check your email


I got it, big thanks!!
9 个月 前
a.m. wrote:
How do we get the updated web API package if we got it in the mobile app bundle? I do not see an updated mobile app bundle to download.
Please check your email


I was able to get the updated web api plugin installed, however now all we get is this error response:

415 - Unsupported Media Type

Here is the code again:

Public Shared Function loadImageNopAPI(ByVal imgUrl As String) As HttpWebResponse
            'get authorization token
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
            Dim authorizationToken = getNopAuthToken()
            'get image data based on image url
            Dim imageByteArray As Byte() = GetDobaImageDataBinary(imgUrl)
            'get mimetype
            Dim mimeType = MimeMapping.GetMimeMapping(imgUrl)
            'do the put call
            Dim response As HttpWebResponse
            If authorizationToken <> "0" Then
                'create request object
                Dim apiCallURL = "(our store base url is here)/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 = mimeType
                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()

                'Get response
                Dim pictureID As Integer
                Try
                    response = httpWebRequest.GetResponse()
                    Dim responseStream = response.GetResponseStream()
                    Dim reader As New StreamReader(responseStream)
                    Dim responseFromServer = reader.ReadToEnd()
                    Dim pictureJson As JObject
                    pictureJson = JObject.Parse(responseFromServer)
                    pictureID = pictureJson.SelectToken("id")
                    'Return pictureID
                    Return response
                Catch ex As WebException
                    Return ex.Response
                End Try
            End If
            Return response
        End Function

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



I have tried multiple tests with different types of images as the incoming data and no matter what we try we get the 415 error now.

Any help would be appreciated, thanks!