Generate B4X code from CURL command
ex.
Output:
Regards.
ex.
B4X:
Dim CURL As B4XcURL
CURL.Initialize
Dim CurlText As String = $"curl https://api.luxand.cloud/photo/verify/1234/
-X POST \
-H "token: 1111111111111" \
-d "name=image1" \
-d "photo=@photo.jpg""$
Log(CURL.GenerateCode(CurlText))
Dim CurlText As String = $"curl -X POST "https://rest.nexmo.com/sms/json" \
-d "from=15558889999" \
-d "text=Hello from Vonage SMS API" \
-d "to=15552279966" \
-d "api_key=9******8" \
-d "api_secret=N************g""$
Log(CURL.GenerateCode(CurlText))
Dim CurlText As String = $"curl -X GET "https://api.example.com/submit" \
-d "{'key1':'value1'}" \
-H "Content-Type: application/json""$
Log(CURL.GenerateCode(CurlText))
Output:
B4X:
Public Sub POSTHttpRequest As String
Dim Result As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.PostString("https://api.luxand.cloud/photo/verify/1234", [{"name":"image1"},{"photo":"@photo.jpg"}])
j.GetRequest.SetHeader("token","1111111111111"
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Result = j.GetString
End If
Catch
Log(LastException)
End Try
j.Release
Return Result
End Sub
Public Sub POSTHttpRequest As String
Dim Result As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.PostString("https://rest.nexmo.com/sms/json", [{"from":"15558889999"},{"text":"Hello from Vonage SMS API"},{"to":"15552279966"},{"api_key":"9******8"},{"api_secret":"N************g"}])
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Result = j.GetString
End If
Catch
Log(LastException)
End Try
j.Release
Return Result
End Sub
Public Sub GETHttpRequest As String
Dim Result As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.Download2("https://api.example.com/submit", ["{'key1':'value1'}"])
j.GetRequest.SetHeader("Content-Type","application/json"
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Result = j.GetString
End If
Catch
Log(LastException)
End Try
j.Release
Return Result
End Sub
Regards.