Code: Select all
Sub Test()
Const sURL As String = "https://oppaapi.emis.gov.eg/api/pl/IsDocumentIdValid"
Dim a, ws As Worksheet, sh As Worksheet, http As Object, sNationalID As String, sResp As String
Set ws = shINF: Set sh = shSN
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
sNationalID = sh.Range("B1").Value
With http
.Open "GET", sURL & "?DocumentId=" & sNationalID & "&IdType=1", False
On Error GoTo ErrBearer
.setRequestHeader "Authorization", Replace(ws.Range("A5").Value, "Authorization: ", Empty)
.setRequestHeader "Referer", "https://student.emis.gov.eg/"
.setRequestHeader "schoolCode", ws.Range("D2").Value
On Error GoTo ErrPoint
.send
sResp = .responseText
End With
ErrPoint:
MsgBox "Operation Aborted", vbExclamation: Exit Sub
ErrBearer:
MsgBox "Get New Authorization", vbExclamation: Exit Sub
End Sub
Posted here too https://chandoo.org/forum/threads/winht ... -10.56240/