iOS Question iHttpUtils2 consume OData

catster

Member
Licensed User
Longtime User
These code works in b4a but failed in b4i

B4X:
    Dim j As HttpJob
      
    j.Initialize("", Me)
    j.JobName = "Test"
    j.Username = "USER"
    j.Password = "password"
    j.Download("https://nav.example.com:7048/HK/OData/Company('HK')/WSStore?$format=json&$select=No,Name,MchID,Appcode,Appkey&$filter=No eq '10'")
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
    j.Release

call with chrome returns
{"odata.metadata":"https://nav.example.com:7048/HK/OData/$metadata#WSStore&$select=No,Name,MchID,Appcode,Appkey","value":[{"odata.etag":"W/\"'20%3BfqTmBQJ7AjEAMAAAAAAA9%3B2857454810%3B'\"","No":"10","Name":"\u5c6f\u9580\u6642\u4ee3","MchID":"XXXXXXXXXXXXXX","Appcode":"XXXXXXXXXXXXXXXXXXXXXXXXXXXX","Appkey":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}]}

after the wait for there is an error
B4X:
Application_Start
Application_Active
Error occurred on line: 279 (HttpJob)
*** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil
Stack Trace: (
  CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 1227356
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 1577824
  CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 1616084
  CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 51648
  Steve's First B4i Example           0x0000000100da3fa0 -[B4IHttp ExecuteCredentials::::] + 292
  Steve's First B4i Example           0x0000000100d5427c -[b4i_httputils2service _submitjob:] + 1228
  CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 1252384
  CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 7472
  Steve's First B4i Example           0x0000000100d61dd8 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
Steve's First B4i Example           0x0000000100dadf38 -[B4IShell runMethod:] + 448
Steve's First B4i Example           0x0000000100daca48 -[B4IShell raiseEventImpl:method:args::] + 1648
Steve's First B4i Example           0x0000000100db0388 -[B4IShellBI raiseEvent:event:params:] + 1580
Steve's First B4i Example           0x0000000100d61168 __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
libdispatch.dylib    A3849F96-1C9F-36C5-A15F-70C566F14CFF + 374288
libdispatch.dylib    A3849F96-1C9F-36C5-A15F-70C566F14CFF + 377220
libdispatch.dylib    A3849F96-1C9F-36C5-A15F-70C566F14CFF + 57744
CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 693732
CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 673240
CoreFoundation       CFRunLoopRunSpecific + 464
GraphicsServices     GSEventRunModal + 104
UIKitCore            UIApplicationMain + 1936
Steve's First B4i Example           0x0000000100d4a5a0 main + 124
libdyld.dylib        2E3F4750-8B67-398B-8530-8417651B1718 + 4960
)
 
Last edited:
Please replace line 7:
my suggestion:
j.Download("https://nav.example.com:7048/HK/OData/Company('HK')/WSStore?$format=json&$select=No,Name,MchID,Appcode,Appkey&$filter=No%20eq%20%2710%27")
Note that space should be replaced by %20 and single quote ' replaced by %27.
 
Upvote 0
Top