I'm trying to use https://api.zomato.com/v2.1/cashless/validateTransaction in vb.net; when I'm using it in postman it works fine and gives response, content-type: multipart/form-data; boundary=. but don't have any idea how to send webclient request with parameters, and content-type: multipart/form-data; boundary=.can any one help me please?
I have tried:
Public Function zomatoText() As String Dim str As String = ""
str = str + " { " + vbCrLf
str = str + " ""mode"":""formdata"", " + vbCrLf
str = str + " ""formdata"": [ " + vbCrLf
str = str + " { " + vbCrLf
str = str + " ""key"": ""res_id"", " + vbCrLf
str = str + " ""value"": ""-1"", " + vbCrLf
str = str + " ""type"": ""text"" " + vbCrLf
str = str + " }, " + vbCrLf
str = str + " { " + vbCrLf
str = str + " ""key"": ""auth_code"", " + vbCrLf
str = str + " ""value"": ""6291"", " + vbCrLf
str = str + " ""type"": ""text"" " + vbCrLf
str = str + " }, " + vbCrLf
str = str + " { " + vbCrLf
str = str + " ""key"": ""order_date"", " + vbCrLf
str = str + " ""value"": ""2019-01-05"", " + vbCrLf
str = str + " ""type"": ""text"" " + vbCrLf
str = str + " }, " + vbCrLf
str = str + " { " + vbCrLf
str = str + " ""key"": ""paid_amount"", " + vbCrLf
str = str + " ""value"": ""2014.50"", " + vbCrLf
str = str + " ""type"": ""text"" " + vbCrLf
str = str + " }, " + vbCrLf
str = str + " { " + vbCrLf
str = str + " ""key"": ""debug"", " + vbCrLf
str = str + " ""value"": ""1"", " + vbCrLf
str = str + " ""type"": ""text"" " + vbCrLf
str = str + " }, " + vbCrLf
str = str + " { " + vbCrLf
str = str + " ""key"": ""partner_id"", " + vbCrLf
str = str + " ""value"": ""1"", " + vbCrLf
str = str + " ""type"": ""text"" " + vbCrLf
str = str + " }, " + vbCrLf
str = str + " { " + vbCrLf
str = str + " ""key"": ""partner_entity_id"", " + vbCrLf
str = str + " ""value"": ""1"", " + vbCrLf
str = str + " ""type"": ""text"" " + vbCrLf
str = str + " } " + vbCrLf
str = str + " ] " + vbCrLf
str = str + " } " + vbCrLf
Return str
End Function
Public Function SendZomato() As String
Try
Dim strv As String = zomatoText() 'fnc1() 'fnc() 't2() ' test_2()'fnc()
Dim url = "https://api.zomato.com/v2.1/cashless/validateTransaction"
Dim client As New WebClient
client.Headers.Add("Content-Type", "multipart/form-data; boundary=<calculated when request is sent>")
client.Headers.Add("X-Zomato-Api-Key", "MyKeyGoesHere")
Dim response As String = client.UploadString(url, strv)
Return response
Catch ex As WebException
MsgBox(ex.Message)
End Try
End Function
Expecting response from request but it is returning "The remote server returned an error: (403) Forbidden."