Skip to main content

Vb Net reference for JSon Extraction of String to Json .

 Public Shared Function SupplementaryUpload(ByVal ICMSIntegrationID As String, ByVal CMSActivityID As String, ByVal File As String, ByVal Flag As String, ByRef ErrorResponse As String) As Boolean
        Try
            'Dim client As New RestSharp.RestClient()
            ' Dim BMJ_LinkUpload As String = ConfigurationManager.AppSettings("BMJ_API_Upload")
            Dim BMJ_LinkUpload As String = "http://is-s2130:5000/BMJIntegration/SupplementaryUpload"
            'client.BaseUrl = New Uri(BMJ_LinkUpload & "?ICMSIntegrationID=" & ICMSIntegrationID & "& CMSActivityID=" & CMSActivityID & "&File=" & File & "&Flag=" & Flag)
            '''?ICMSIntegrationID=56445096&CMSActivityID=29&File=D:\admin.JPG&Flag=article_resource")
            'client.Timeout = -1
            'Dim request = New RestRequest(Method.[GET])
            'Dim response As IRestResponse = client.Execute(request)
            'Return response.Content
            Dim fi As FileInfo = New FileInfo(File)
            Dim length As Long = fi.Length

            Dim client As New RestSharp.RestClient()
            client.BaseUrl = New Uri(BMJ_LinkUpload & "?ICMSIntegrationID=" & ICMSIntegrationID & "& CMSActivityID=" & CMSActivityID & "&File=" & File & "&Flag=" & Flag)
            ''?ICMSIntegrationID=56445096&CMSActivityID=29&File=D:\admin.JPG&Flag=article_resource")
            client.Timeout = -1
            Dim request = New RestRequest(Method.[GET])
            Dim response As IRestResponse = client.Execute(request)
            Dim UploadResponse As JObject
            Dim sDatajobject As JObject
            'Response = New Response()
            ''Method added by Rajagopal
            'InsertSupplementaryUpload("SupplementaryUpload", client.BaseUrl.AbsoluteUri, response.Content)

            'UploadResponse = JsonConvert.DeserializeObject(Of Response)(response.Content.Replace("/", "\"))

            ' Dim responseMessage As String = JsonConvert.SerializeObject(UploadResponse.message.ToString())

            UploadResponse = JObject.Parse(response.Content)

            If (UploadResponse.GetValue("is_success")) Then


                Dim sData As String = UploadResponse.GetValue("data")
                Dim ThisToken As JToken = Newtonsoft.Json.JsonConvert.DeserializeObject(Of JToken)(sData)

                sDatajobject = JObject.Parse(ThisToken)
                Dim sUploadedFilesize As String = sDatajobject.GetValue("size")
                '  Return response.Content
                Return True
            Else
                ErrorResponse = UploadResponse.GetValue("message").ToString()
                Return False
            End If
        Catch ex As Exception
            Return ex.Message
        End Try
    End Function

Comments

Popular posts from this blog

Hosting multiple Environments

using   System ; using   System . Collections . Generic ; using   System . Linq ; using   System . Threading . Tasks ; using   Microsoft . AspNetCore . Builder ; using   Microsoft . AspNetCore . Hosting ; using   Microsoft . AspNetCore . HttpsPolicy ; using   Microsoft . AspNetCore . Mvc ; using   Microsoft . Extensions . Configuration ; using   Microsoft . Extensions . DependencyInjection ; using   Microsoft . Extensions . Hosting ; using   Microsoft . Extensions . Logging ; using   Microsoft . EntityFrameworkCore ; using   MovejobtoWms . Models ; using   Microsoft . AspNetCore . Authentication . Cookies ; using   Microsoft . AspNetCore . Authentication ; using   Newtonsoft . Json ; using   Microsoft . AspNetCore . Http ; using   System . Net . Http . Headers ; namespace   MovejobtoWms {      public   class   Star...

Code Example Zip File Extraction and Download in dotnet core api

using   System . Security . Principal ; using   Microsoft . Win32 . SafeHandles ; using   System . Dynamic ; using   System . Reflection . Metadata . Ecma335 ; using   System . Reflection . Metadata ; using   System . Text ; using   System . Runtime . CompilerServices ; using   System . Net . Http ; using   System ; using   System . Collections . Generic ; using   System . Linq ; using   System . Net . Mime ; using   System . Threading . Tasks ; using   Microsoft . AspNetCore . Http ; using   Microsoft . AspNetCore . Mvc ; using   Microsoft . EntityFrameworkCore ; using   MovejobtoWms . Models ; using   System . IO ; using   System . Net ; using   Microsoft . AspNetCore . Authorization ; using   System . IO . Compression ; using   System . Net . Http . Headers ; using   System . Net . Http . Formatting ; using   System ...