User Tools

Site Tools


integration_with_other_systems

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
integration_with_other_systems [2022/01/14 16:48] – ↷ Links adapted because of a move operation 127.0.0.1integration_with_other_systems [2024/04/04 10:18] (current) – [Troubleshooting CURL requests from WebHMI] emozolyak
Line 118: Line 118:
  
 If the curl stability is the issue in your project, you can implement HTTP requests using custom protocol. See the [[http_get_custom |example]] If the curl stability is the issue in your project, you can implement HTTP requests using custom protocol. See the [[http_get_custom |example]]
 +</WRAP>
  
 +==== HTTP / HTTPS requests ====
 +<WRAP center round info 80%>
 +Please note that HTTPS requests are only possible in **WebHMI Pro** version and virtualization images.
 </WRAP> </WRAP>
 +
 +==== Troubleshooting CURL requests from WebHMI ====
 +
 +When troubleshooting your requests, you can turn on verbose information in your script. Please refer to the example below:
 +
 +<code lua>
 +function main (userId)
 +    local res = ""    
 +    local c = cURL.easy_init()
 +    c : setopt{ url = 'http://danepubliczne.imgw.pl/api/data/hydro/id/153160210',
 +              timeout = 30, 
 +              httpheader = {'Accept: application/json',
 +                            'Content-Type: gzip, deflate, br',
 +                            -- 'Host: <calculated when request is sent>',
 +                        }
 +             }
 +     
 +     -- sw on verbose info 
 +     c : setopt{[cURL.OPT_VERBOSE] = 1}  
 +     c : setopt{[cURL.OPT_DEBUGFUNCTION] = function(...) 
 +                for i, v in pairs(arg) do DEBUG(i .. ' ' .. v) end 
 +                return 0
 +         end }  
 +     
 +     c : perform{writefunction = function(str)
 +                res = res .. str
 +            end}
 +        c : close()
 +     
 +        INFO(res)
 +        if (res == '') or (res == '%[%]')then 
 +            ERROR('No data in response!'
 +        else 
 +            INFO('\n' .. res) 
 +        end
 +end
 +</code>
 +
 +
  
  
integration_with_other_systems.1642178907.txt.gz · Last modified: 2022/01/14 16:48 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki