K kostefar Active Member Licensed User Longtime User Jul 30, 2019 #1 Dear All, I´m using jokhttputils2 trying to authenticate a request with the following: Code: Copy httpjob.Username = "user" httpjob.Password = "pass" httpjob.PostString ( "https://api.vat-search.eu/v2/bulk_search/?cutoff_score=1" , $"[ {"n": "Linkomat GmbH","a": "1150","cc": "at"}, {"n": "Google","a": ""} ]"$) ) Based on that in the manual it states: Example: curl -XPOST "https://api.vat-search.eu/v2/bulk_search/?cutoff_score=1" -d '[ {"n": "Linkomat GmbH","a": "1150","cc": "at"}, {"n": "Google","a": ""} ]' 2. Authentication We support Basic Authentication with the assigned user name and password setup Click to expand... But I keep getting Code: Copy {"error":"Authentication required"} I manage to logon to their web interface via chrome easily, but the API just won´t work for me. I tried having username & password both before and after the poststring. Any idea what´s going wrong? Last edited: Jul 30, 2019
Dear All, I´m using jokhttputils2 trying to authenticate a request with the following: Code: Copy httpjob.Username = "user" httpjob.Password = "pass" httpjob.PostString ( "https://api.vat-search.eu/v2/bulk_search/?cutoff_score=1" , $"[ {"n": "Linkomat GmbH","a": "1150","cc": "at"}, {"n": "Google","a": ""} ]"$) ) Based on that in the manual it states: Example: curl -XPOST "https://api.vat-search.eu/v2/bulk_search/?cutoff_score=1" -d '[ {"n": "Linkomat GmbH","a": "1150","cc": "at"}, {"n": "Google","a": ""} ]' 2. Authentication We support Basic Authentication with the assigned user name and password setup Click to expand... But I keep getting Code: Copy {"error":"Authentication required"} I manage to logon to their web interface via chrome easily, but the API just won´t work for me. I tried having username & password both before and after the poststring. Any idea what´s going wrong?
OliverA Expert Licensed User Longtime User Jul 30, 2019 #2 This (in your code sample): kostefar said: "https://api.vat-search.eu/v2/bulk_search/?cutoff_score=1https://api.vat-search.eu" Click to expand... Is not this "https://api.vat-search.eu/v2/bulk_search/?cutoff_score=1" Click to expand... from the example. You have an extra https://api.vat-search.eu on the end of your string Upvote 0
This (in your code sample): kostefar said: "https://api.vat-search.eu/v2/bulk_search/?cutoff_score=1https://api.vat-search.eu" Click to expand... Is not this "https://api.vat-search.eu/v2/bulk_search/?cutoff_score=1" Click to expand... from the example. You have an extra https://api.vat-search.eu on the end of your string
K kostefar Active Member Licensed User Longtime User Jul 30, 2019 #3 OliverA said: This (in your code sample): Is not this from the example. You have an extra https://api.vat-search.eu on the end of your string Click to expand... Sorry, my bad. Corrected it now. Result is like before though. Upvote 0
OliverA said: This (in your code sample): Is not this from the example. You have an extra https://api.vat-search.eu on the end of your string Click to expand... Sorry, my bad. Corrected it now. Result is like before though.
K kostefar Active Member Licensed User Longtime User Jul 30, 2019 #5 OliverA said: Link to documentation? Click to expand... https://vat-search.eu/src/pdf/docs2.pdf Which also contains a GET method that´s simpler, but gives the same result. I should add that I also tried with Code: Copy user:password@URL authentication, but with no luck either. Upvote 0
OliverA said: Link to documentation? Click to expand... https://vat-search.eu/src/pdf/docs2.pdf Which also contains a GET method that´s simpler, but gives the same result. I should add that I also tried with Code: Copy user:password@URL authentication, but with no luck either.
OliverA Expert Licensed User Longtime User Jul 31, 2019 #6 HttpJob correctly creates the basic authentication header (by request). It looks like the username and password you are providing is not correct. I verified HttpJobs basic authentication against postman-echo.com: Code: Copy 'Non-UI application (console / server application) #Region Project Attributes #CommandLineArgs: #MergeLibraries: True #End Region Sub Process_Globals End Sub Sub AppStart (Args() As String) testpost StartMessageLoop End Sub Sub testpost Dim job As HttpJob job.Initialize("", Me) 'job.Username = "[email protected]" 'job.Password = "guessme!" job.Username = "postman" job.Password = "password" job.Download("https://postman-echo.com/basic-auth") 'job.Download("https://api.vat-search.eu/v2/?n=Linkomat&cc=at") Wait For (job) JobDone(job As HttpJob) If job.Success Then Log("Success!!!") Log(job.GetString) Else Log("OOOPS") Log(job.ErrorMessage) End If job.Release StopMessageLoop End Sub 'Return true to allow the default exceptions handler to handle the uncaught exception. Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub Upvote 0
HttpJob correctly creates the basic authentication header (by request). It looks like the username and password you are providing is not correct. I verified HttpJobs basic authentication against postman-echo.com: Code: Copy 'Non-UI application (console / server application) #Region Project Attributes #CommandLineArgs: #MergeLibraries: True #End Region Sub Process_Globals End Sub Sub AppStart (Args() As String) testpost StartMessageLoop End Sub Sub testpost Dim job As HttpJob job.Initialize("", Me) 'job.Username = "[email protected]" 'job.Password = "guessme!" job.Username = "postman" job.Password = "password" job.Download("https://postman-echo.com/basic-auth") 'job.Download("https://api.vat-search.eu/v2/?n=Linkomat&cc=at") Wait For (job) JobDone(job As HttpJob) If job.Success Then Log("Success!!!") Log(job.GetString) Else Log("OOOPS") Log(job.ErrorMessage) End If job.Release StopMessageLoop End Sub 'Return true to allow the default exceptions handler to handle the uncaught exception. Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub
K kostefar Active Member Licensed User Longtime User Jul 31, 2019 #7 OliverA said: HttpJob correctly creates the basic authentication header (by request). It looks like the username and password you are providing is not correct. I verified HttpJobs basic authentication against postman-echo.com: Code: Copy 'Non-UI application (console / server application) #Region Project Attributes #CommandLineArgs: #MergeLibraries: True #End Region Sub Process_Globals End Sub Sub AppStart (Args() As String) testpost StartMessageLoop End Sub Sub testpost Dim job As HttpJob job.Initialize("", Me) 'job.Username = "[email protected]" 'job.Password = "guessme!" job.Username = "postman" job.Password = "password" job.Download("https://postman-echo.com/basic-auth") 'job.Download("https://api.vat-search.eu/v2/?n=Linkomat&cc=at") Wait For (job) JobDone(job As HttpJob) If job.Success Then Log("Success!!!") Log(job.GetString) Else Log("OOOPS") Log(job.ErrorMessage) End If job.Release StopMessageLoop End Sub 'Return true to allow the default exceptions handler to handle the uncaught exception. Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub Click to expand... Thanks so much! I assume that there´s no difference between whether this is NON_UI or UI, which is what I have? Silly question, only trying to find any possible reason other than the credentials not being correct before I go back to the support of the service again. Upvote 0
OliverA said: HttpJob correctly creates the basic authentication header (by request). It looks like the username and password you are providing is not correct. I verified HttpJobs basic authentication against postman-echo.com: Code: Copy 'Non-UI application (console / server application) #Region Project Attributes #CommandLineArgs: #MergeLibraries: True #End Region Sub Process_Globals End Sub Sub AppStart (Args() As String) testpost StartMessageLoop End Sub Sub testpost Dim job As HttpJob job.Initialize("", Me) 'job.Username = "[email protected]" 'job.Password = "guessme!" job.Username = "postman" job.Password = "password" job.Download("https://postman-echo.com/basic-auth") 'job.Download("https://api.vat-search.eu/v2/?n=Linkomat&cc=at") Wait For (job) JobDone(job As HttpJob) If job.Success Then Log("Success!!!") Log(job.GetString) Else Log("OOOPS") Log(job.ErrorMessage) End If job.Release StopMessageLoop End Sub 'Return true to allow the default exceptions handler to handle the uncaught exception. Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub Click to expand... Thanks so much! I assume that there´s no difference between whether this is NON_UI or UI, which is what I have? Silly question, only trying to find any possible reason other than the credentials not being correct before I go back to the support of the service again.
Erel B4X founder Staff member Licensed User Longtime User Jul 31, 2019 #8 kostefar said: I assume that there´s no difference between whether this is NON_UI or UI, which is what I have? Click to expand... True. Just remove StartMessageLoop / StopMessageLoop calls. Upvote 0
kostefar said: I assume that there´s no difference between whether this is NON_UI or UI, which is what I have? Click to expand... True. Just remove StartMessageLoop / StopMessageLoop calls.
K kostefar Active Member Licensed User Longtime User Jul 31, 2019 #9 Thank you, I ended up doing the following which worked: httpjob.GetRequest.SetHeader ("Authorization", "Basic dXNlcm5hbWU6cGFzc3dvcmQ=") The base64 encoded string "usernameassword" encoded. Upvote 0
Thank you, I ended up doing the following which worked: httpjob.GetRequest.SetHeader ("Authorization", "Basic dXNlcm5hbWU6cGFzc3dvcmQ=") The base64 encoded string "usernameassword" encoded.
OliverA Expert Licensed User Longtime User Jul 31, 2019 #10 kostefar said: I ended up doing the following which worked: Click to expand... The sad thing is, you should not have to do this. I used PTS-V2 (https://ptsv2.com) to test authentication and it just works. Even the UI version. The header looks just like it should. Code: Copy #Region Project Attributes #MainFormWidth: 600 #MainFormHeight: 600 #End Region Sub Process_Globals Private fx As JFX Private MainForm As Form End Sub Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file. MainForm.Show testpost End Sub Sub testpost Dim job As HttpJob job.Initialize("", Me) job.Username = "[email protected]" job.Password = "guessme!" 'job.Username = "postman" 'job.Password = "password" 'job.Username = "test" 'job.Password = "test" job.PostString("https://ptsv2.com/t/createyourowntoilet/post","test") 'job.Download("https://postman-echo.com/basic-auth") 'job.Download("https://api.vat-search.eu/v2/?n=Linkomat&cc=at") Wait For (job) JobDone(job As HttpJob) If job.Success Then Log("Success!!!") Log(job.GetString) Else Log("OOOPS") Log(job.ErrorMessage) End If job.Release End Sub 'Return true to allow the default exceptions handler to handle the uncaught exception. Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub Upvote 0
kostefar said: I ended up doing the following which worked: Click to expand... The sad thing is, you should not have to do this. I used PTS-V2 (https://ptsv2.com) to test authentication and it just works. Even the UI version. The header looks just like it should. Code: Copy #Region Project Attributes #MainFormWidth: 600 #MainFormHeight: 600 #End Region Sub Process_Globals Private fx As JFX Private MainForm As Form End Sub Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file. MainForm.Show testpost End Sub Sub testpost Dim job As HttpJob job.Initialize("", Me) job.Username = "[email protected]" job.Password = "guessme!" 'job.Username = "postman" 'job.Password = "password" 'job.Username = "test" 'job.Password = "test" job.PostString("https://ptsv2.com/t/createyourowntoilet/post","test") 'job.Download("https://postman-echo.com/basic-auth") 'job.Download("https://api.vat-search.eu/v2/?n=Linkomat&cc=at") Wait For (job) JobDone(job As HttpJob) If job.Success Then Log("Success!!!") Log(job.GetString) Else Log("OOOPS") Log(job.ErrorMessage) End If job.Release End Sub 'Return true to allow the default exceptions handler to handle the uncaught exception. Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub
K kostefar Active Member Licensed User Longtime User Jul 31, 2019 #11 OliverA said: The sad thing is, you should not have to do this. I used PTS-V2 (https://ptsv2.com) to test authentication and it just works. Even the UI version. The header looks just like it should. Code: Copy #Region Project Attributes #MainFormWidth: 600 #MainFormHeight: 600 #End Region Sub Process_Globals Private fx As JFX Private MainForm As Form End Sub Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file. MainForm.Show testpost End Sub Sub testpost Dim job As HttpJob job.Initialize("", Me) job.Username = "[email protected]" job.Password = "guessme!" 'job.Username = "postman" 'job.Password = "password" 'job.Username = "test" 'job.Password = "test" job.PostString("https://ptsv2.com/t/createyourowntoilet/post","test") 'job.Download("https://postman-echo.com/basic-auth") 'job.Download("https://api.vat-search.eu/v2/?n=Linkomat&cc=at") Wait For (job) JobDone(job As HttpJob) If job.Success Then Log("Success!!!") Log(job.GetString) Else Log("OOOPS") Log(job.ErrorMessage) End If job.Release End Sub 'Return true to allow the default exceptions handler to handle the uncaught exception. Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub Click to expand... Agree, it´s very strange why that other site won´t do what it should logging on in a proper manner with basic authentication but what matters is that it now works for me. Thanks again for trying! Upvote 0
OliverA said: The sad thing is, you should not have to do this. I used PTS-V2 (https://ptsv2.com) to test authentication and it just works. Even the UI version. The header looks just like it should. Code: Copy #Region Project Attributes #MainFormWidth: 600 #MainFormHeight: 600 #End Region Sub Process_Globals Private fx As JFX Private MainForm As Form End Sub Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file. MainForm.Show testpost End Sub Sub testpost Dim job As HttpJob job.Initialize("", Me) job.Username = "[email protected]" job.Password = "guessme!" 'job.Username = "postman" 'job.Password = "password" 'job.Username = "test" 'job.Password = "test" job.PostString("https://ptsv2.com/t/createyourowntoilet/post","test") 'job.Download("https://postman-echo.com/basic-auth") 'job.Download("https://api.vat-search.eu/v2/?n=Linkomat&cc=at") Wait For (job) JobDone(job As HttpJob) If job.Success Then Log("Success!!!") Log(job.GetString) Else Log("OOOPS") Log(job.ErrorMessage) End If job.Release End Sub 'Return true to allow the default exceptions handler to handle the uncaught exception. Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub Click to expand... Agree, it´s very strange why that other site won´t do what it should logging on in a proper manner with basic authentication but what matters is that it now works for me. Thanks again for trying!