![]() |
|
[VB.NET] مساعدة فى كود فاتورة اللكترونية - نسخة قابلة للطباعة +- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb) +-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182) +--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183) +--- الموضوع : [VB.NET] مساعدة فى كود فاتورة اللكترونية (/showthread.php?tid=47983) |
مساعدة فى كود فاتورة اللكترونية - asdfar1977 - 28-02-24 الشباب المحترمين عندى كود به مشكله هذا الكود المطلوب منه احضار بيانات من موقع الفاتورة الالكترونيه يفيد بان الفاتورة تم استلامها ويرد برقم الفاتورة الالكترونى حتى اتاكد من ان الفاتورة التى قمت بارسالها لموقع الضرائب تم قبولها وهذا هو الكود وللعلم فان هذا الكود يقوم بانشاء ملف جسون طبقا للمسار ادناه ولكن لا يعطى البيانات المطلوب يرجى الافادة والتعديل على هذا الكود حتى يفى المطلوب ارجو اعتبار الموضوع هام Private Sub SurroundingSub()
tok = 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 eyJhbGciOiJSUzI1 " & tok) Dim body = "{ " & vbLf & " ""type"": ""Summary"", " & vbLf & " ""format"": ""JSON"", " & vbLf & " ""queryParameters"": { " & vbLf & " ""dateFrom"": ""2024-02-27T21:00:28.451Z"", " & vbLf & " ""dateTo"": ""2024-02-28T21:00:28.451Z"", " & vbLf & " ""statuses"": [ " & vbLf & " ""Valid"", " & vbLf & " ""Cancelled"", " & vbLf & " ""Rejected"" " & vbLf & " ], " & vbLf & " ""productsInternalCodes"": [], " & vbLf & " ""receiverSenderId"": """", " & vbLf & " ""receiverSenderType"": ""0"", " & vbLf & " ""branchNumber"": """", " & vbLf & " ""itemCodes"": [ " & vbLf & " { " & vbLf & " ""codeValue"": """", " & vbLf & " ""codeType"": """" " & vbLf & " } " & vbLf & " ], " & vbLf & " ""documentTypeNames"": [] " & vbLf & " } " & vbLf & "}" Dim result As IRestResponse = client.Execute(request.AddJsonBody(body)) If result.Content <> "" Then Dim o As JObject = JObject.Parse(result.Content) End If Dim json As String = JsonConvert.SerializeObject(body, Formatting.Indented) Dim path As String = "C:\server\Json001.json" File.WriteAllText(path, json) MessageBox.Show("done01") End Sub RE: مساعدة فى كود فاتورة اللكترونية - asdfar1977 - 29-02-24 الاخ المحترم 3sem نفذت التعديل ولكن الكود لا يعمل ارجو الاهتمام بالموضوع RE: مساعدة فى كود فاتورة اللكترونية - asdfar1977 - 02-03-24 هذا هو الكود الصحيح 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 |