How I would probably do it

I think that the duplication of the actual httpc:request is fine, because that part is actually quite different from the two different requests you make. So I made them into two different functions and abstracted the handling of the response instead. I think this is clearer to see what you are doing and how they are different.

Note: this was done in the Github editor so untested :P