{"id":941,"date":"2020-03-09T16:04:10","date_gmt":"2020-03-09T14:04:10","guid":{"rendered":"https:\/\/www.rocworks.at\/wordpress\/?p=941"},"modified":"2020-05-06T23:14:05","modified_gmt":"2020-05-06T21:14:05","slug":"use-graphql-in-wincc-oa","status":"publish","type":"post","link":"https:\/\/www.rocworks.at\/wordpress\/?p=941","title":{"rendered":"Use GraphQL in WinCC OA &#8230;"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This is a simple example how to query a GraphQL server from WinCC OA ctrl via HTTP.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  string url = \"https:\/\/server.rocworks.at\/graphql\";\n\n  string query = \"query($tag: String!){getTag(name: $tag){tag{current{value}}}}\";\n\n  mapping variables = makeMapping(\"tag\", \"Input\");\n\n  mapping content = makeMapping(\"query\", query, \"variables\", variables);\n\n  mapping data = makeMapping(\n      \"headers\", makeMapping(\"Content-Type\", \"application\/json\"),\n      \"content\", jsonEncode(content)\n  );\n\n  mapping result;\n\n  netPost(url, data, result);\n\n  if (result&#91;\"httpStatusText\"]==\"OK\") {\n    DebugTN(result&#91;\"content\"]);\n  }\n  else {\n    return \"Error\";\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n   \"data\": {\n     \"getTag\": {\n       \"tag\": {\n         \"current\": {\n           \"value\": 280.87696028711866\n         }\n       }\n     }\n   }\n }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is a simple example how to query a GraphQL server from WinCC OA ctrl via HTTP. Output:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-941","post","type-post","status-publish","format-standard","hentry","category-wincc-oa"],"_links":{"self":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=941"}],"version-history":[{"count":4,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/941\/revisions"}],"predecessor-version":[{"id":962,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/941\/revisions\/962"}],"wp:attachment":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}