c++ libcurl json rest

后端 未结 3 1037
青春惊慌失措
青春惊慌失措 2020-12-08 12:13

I am trying to download a json file from a REST webpage in C++ with libcurl. The following code works if I go to the webpage but it doesnt download if I try to access the js

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 13:00

    I think this has to do with the configuration on the HTTP server. First, you should be sending some type of indication of what type you're expecting, for example, adding an Accept header like this:

    Accept: application/json
    

    If you don't specify what you're expecting, the server may return the default HTML in the response header Content-Type, and that's what curl says to you.

提交回复
热议问题