Android Question Patch Request throwing error?

ilan

Expert
Licensed User
Longtime User
hi,

i am building a REST Api in b4j and i am making calls from a b4a app (latter also from b4i).

GET / POST / PUT / DELETE works without any issues but PATCH is not working. it is giving me an error:

ResponseError. Reason: Not Implemented, Response:

code:

B4X:
Dim j As HttpJob
    j.Initialize("", Me)
    Dim json As JSONGenerator
    json.Initialize(CreateMap( _
                            "username":"daniel123", _
                            "lastname":"klein", _
                            "comments":"Comment will be updated."))
    j.PatchString($"${api_url}/patch-user"$,json.ToPrettyString(0))
    j.GetRequest.SetHeader("api-host","/patch-user")
    j.GetRequest.SetHeader("api-key",api_key)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
    j.Release
 

drgottjr

Expert
Licensed User
Longtime User
not implemented is a 501 http error. either the server does not allow patch or it doesn't know what to do with such a request. this is something that the server needs to handle. if the server is yours, you write a routine to handle patch requests. if it's not yours, you need to talk to the server admin. much like put, this is a dangerous request. http servers are not required to handle put and patch. and in cases where they do, an implementation needs to be crafted.
 
Upvote 1

ilan

Expert
Licensed User
Longtime User
it is my server that i created in b4j. i am handling all requests methods and all other works fine. the PatchString method does not even reach the Handle() event.
i think there is a bug in b4j jServer library.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
it is my server that i created in b4j. i am handling all requests methods and all other works fine. the PatchString method does not even reach the Handle() event.
i think there is a bug in b4j jServer library.
I guess perhaps jetty does not implement patch method, but not Jserver
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
I guess perhaps jetty does not implement patch method, but not Jserver

it says that it is supported
 
Upvote 0

teddybear

Well-Known Member
Licensed User
it says that it is supported
On jetty sever side, it supports GET HEAD POST PUT DELETE OPTIONS and TRACE, but PATCH method is not implemented, you can see that in HttpServlet.class , so your handler never get the Patch method requested
 
Upvote 1
Top