تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] مساعدة فى كود فاتورة اللكترونية
#3
هذا هو الكود الصحيح
Private Sub SurroundingSub()
Dim client = New RestClient(Config_C.BaseUrl & "/api/v1.0/documents/recent")
''الخطوة رقم 2 تتمثل فى تعريف الطلب الذى تريدة هل هو ارسال الى الخادم ام استقبال من الخادم - منظومة الضرائب
Dim request = New RestRequest(Method.GET)
''الخطوة رقم 3وهى ادخال تعريفات التوكين حتى يفتح لك الباب
Dim tok = GetBearerToken()
'request.AddHeader("authorization", "Bearer " & tok)
'---------
'Dim tok As String = GetBearerToken()
'Dim options As String = "https://api.invoicing.eta.gov.eg"
'Dim client = New RestClient(options)
'Dim request = New RestRequest("/api/v1/documentPackages/requests", Method.POST)
request.AddHeader("Content-Type", "application/json")
request.AddHeader("Authorization", "Bearer " & tok)

' Construct the JSON body for the request
Dim body As String = "
{
""type"": ""I"",
""format"": ""JSON"",
""queryParameters"": {
""dateFrom"": ""2024-02-24T21:00:28.451Z"",
""dateTo"": ""2024-03-28T21:00:28.451Z"",
""statuses"": [
""Valid"",
""Cancelled"",
""Rejected""
],
""productsInternalCodes"": [],
""receiverSenderId"": """",
""receiverSenderType"": ""0"",
""branchNumber"": """",
""itemCodes"": [
{
""codeValue"": """",
""codeType"": """"
}
],
""documentTypeNames"": []
}
}"

' Add the JSON body to the request
request.AddParameter("application/json", body, ParameterType.RequestBody)

' Execute the request
Dim result As IRestResponse = client.Execute(request)

' Check if the response content is not empty
If Not String.IsNullOrEmpty(result.Content) Then
' Parse the response content as JSON
Dim o As JObject = JObject.Parse(result.Content)

' Serialize the JSON body for logging
Dim json As String = JsonConvert.SerializeObject(o, Formatting.Indented)

' Write the JSON body to a file
Dim path As String = "C:\server\Json001.json"
File.WriteAllText(path, json)

MessageBox.Show("Done")
Else
MessageBox.Show("Error: Empty response received.")
End If
End Sub
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
RE: مساعدة فى كود فاتورة اللكترونية - بواسطة asdfar1977 - 02-03-24, 02:00 AM


التنقل السريع :


يقوم بقرائة الموضوع: