Hello,
I have a problem, when I send a request via Curl it works perfectly using PostString I get an error like
ResponseError. Reason:, Response: {"errors": "Unsupported Content-Type"}
How can I fix the problem?
Thanks
I have a problem, when I send a request via Curl it works perfectly using PostString I get an error like
ResponseError. Reason:, Response: {"errors": "Unsupported Content-Type"}
How can I fix the problem?
Thanks
Prg test:
CURL EXAMPLE (WORKING)
curl -X POST https://mamamilano.it/api/2022-04/graphql.json --header "Content-Type: application/graphql" --header "X-Shopify-Storefront-Access-Token: 103e090cf984b47fc28867d2a538b562" --data "{ customer(customerAccessToken: ""00286f5a065ef1f6f3d79cbb699dd009"") { id, firstName, lastName}}"
Response
{"data":{"customer":{"id":"gid:\/\/shopify\/Customer\/6154312974587","firstName":"Info","lastName":"Brambilla"}}}
B4X Conversion
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Dim job1 As HttpJob
job1.Initialize("",Me)
Dim GetUser As String = "{ customer(customerAccessToken: ""00286f5a065ef1f6f3d79cbb699dd009"") { id, firstName, lastName}}"
job1.PostString("https://www.mamamilano.it/api/2022-01/graphql.json", GetUser)
job1.GetRequest.SetHeader("X-Shopify-Storefront-Access-Token","103e090cf984b47fc28867d2a538b562")
job1.GetRequest.SetHeader("Content-Type","application/graphql")
'job1.GetRequest.SetContentType("application/json")
Wait For (job1) JobDone(job1 As HttpJob)
If job1.Success = True Then
Log("Job:" & job1.JobName & "Success OK" )
Dim res As String
res = job1.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Else
Log("Error: " & job1.ErrorMessage)
End If
End Sub