Getting an error of
main$ResumableSub_SyncWebProduct.resume (java line: 233)
java.lang.NullPointerException
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest.SetHeader(OkHttpClientWrapper.java:470)
at b4j.example.main$ResumableSub_SyncWebProduct.resume(main.java:233)
at b4j.example.main._v0(main.java:188)
at b4j.example.main._appstart(main.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
at b4j.example.main.start(main.java:38)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
see code below
Sub AddNewProductToWeb
Dim j As HttpJob
Dim Link As String = "https://staging.test.com/index.php?route=api/custom/addProduct"
Dim data As Map
data.Initialize
data.Put("product_name","This Is a test product")
data.Put("price","This Is a test product")
data.Put("model","SAMSUNG")
data.Put("sku","37976979")
data.Put("category_id","5")
data.Put("manufacturer_id","71")
j.Initialize("test", Me)
j.GetRequest.SetHeader("Content-Type", "multipart/form-data")
j.GetRequest.SetHeader("key","EKBPhjMQOiqcV05qJzV2OY2wdDHwSoBZ1fwc5")
j.GetRequest.SetHeader("username","johndoe")
j.PostMultipart(Link, data,Null)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
'The result is a json string. We parse it and log the fields.
Log(j.GetString)
fx.Msgbox(MainForm, j.GetString,"")
End If
j.Release
End Sub
thanks