I was calling an API which requires UUID version 4 to set as one of the headers. I decided to use this website ( https://www.uuidgenerator.net/ ) API to generate the UUID which works fine.
Later, I started looking for ways to generate the UUID v4 internally in the app so I came across this thread - https://www.b4x.com/android/forum/threads/b4x-guid.99529/#content
Anyways, I learnt UUID is like a subset of GUID, so I decided to use this B4X GUID code to generate the UUID but when I use it, I get ResponseError. Reason: Bad Request, Response: invalid data was sent in the request.
Even if i change it to lowercase, i still get error
But from the same thread when i use colboy's code in post #3, I get a positive response from the API
I need Cross-Platform solution, Does it mean the GUID cannot be used as UUID or is not UUID version 4 compliant?
Later, I started looking for ways to generate the UUID v4 internally in the app so I came across this thread - https://www.b4x.com/android/forum/threads/b4x-guid.99529/#content
Anyways, I learnt UUID is like a subset of GUID, so I decided to use this B4X GUID code to generate the UUID but when I use it, I get ResponseError. Reason: Bad Request, Response: invalid data was sent in the request.
Even if i change it to lowercase, i still get error
Sub GUID As String
Dim sb As StringBuilder
sb.Initialize
For Each stp As Int In Array(8, 4, 4, 4, 12)
If sb.Length > 0 Then sb.Append("-")
For n = 1 To stp
Dim c As Int = Rnd(0, 16)
If c < 10 Then c = c + 48 Else c = c + 55
sb.Append(Chr(c))
Next
Next
Return sb.ToString
End Sub
Dim sb As StringBuilder
sb.Initialize
For Each stp As Int In Array(8, 4, 4, 4, 12)
If sb.Length > 0 Then sb.Append("-")
For n = 1 To stp
Dim c As Int = Rnd(0, 16)
If c < 10 Then c = c + 48 Else c = c + 55
sb.Append(Chr(c))
Next
Next
Return sb.ToString
End Sub
But from the same thread when i use colboy's code in post #3, I get a positive response from the API
Sub GetGuid As String
Dim r As Reflector
r.Target = r.RunStaticMethod("java.util.UUID", "randomUUID", Null, Null)
Return r.RunMethod("toString")
End Sub
Dim r As Reflector
r.Target = r.RunStaticMethod("java.util.UUID", "randomUUID", Null, Null)
Return r.RunMethod("toString")
End Sub
I need Cross-Platform solution, Does it mean the GUID cannot be used as UUID or is not UUID version 4 compliant?