1.很久没做http接口了,都快不会了。。。
最近遇到一个奇葩的,调用http接口返回空,什么都没有,然后用工具测试,发现能返回消息,不过状态是500。。。
好奇之下就在代码里加个个取返回状态code的代码:
lo_http_client->response->get_status( IMPORTING code = v_i reason = v_s ).
结果返回的code是426。。。
然后一查才发现,对方因为http protocol协议低报错。。。
那怎么处理呢。
在request里加一句代码就可以了
lo_http_client->request->if_http_entity~set_header_field( name = '~server_protocol' value = 'HTTP/1.1' ).
神奇。。。我都以为要升级系统的服务协议了。。。结果设置一下就可以,费解,这样的意义是啥。
2.x-www-form-url_encoded格式的报文
抬头设置
lo_http_client->request->if_http_entity~set_content_type( content_type = 'application/x-www-form-url_encoded' ).
然后body通过send data或者send cdata发送,格式xxxxid=xxxxvalue&xxxxxid2=xxxxxvalue2.
^_^很多人都把资料锁进了note里,以后还怎么百度呢^_^