{"record":{"id":"3daf5d670c708f6c","repo":"cloudflare/cloudflared","slug":"rest-request-failed-3daf5d","errorCode":null,"errorMessage":"REST request failed","messagePattern":"REST request failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cfapi/virtual_network.go","lineNumber":56,"sourceCode":"\tdeletedColumn := \"-\"\n\tif !virtualNetwork.DeletedAt.IsZero() {\n\t\tdeletedColumn = virtualNetwork.DeletedAt.Format(time.RFC3339)\n\t}\n\treturn fmt.Sprintf(\n\t\t\"%s\\t%s\\t%s\\t%s\\t%s\\t%s\\t\",\n\t\tvirtualNetwork.ID,\n\t\tvirtualNetwork.Name,\n\t\tstrconv.FormatBool(virtualNetwork.IsDefault),\n\t\tvirtualNetwork.Comment,\n\t\tvirtualNetwork.CreatedAt.Format(time.RFC3339),\n\t\tdeletedColumn,\n\t)\n}\n\nfunc (r *RESTClient) CreateVirtualNetwork(newVnet NewVirtualNetwork) (VirtualNetwork, error) {\n\tresp, err := r.sendRequest(\"POST\", r.baseEndpoints.accountVnets, newVnet)\n\tif err != nil {\n\t\treturn VirtualNetwork{}, errors.Wrap(err, \"REST request failed\")\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode == http.StatusOK {\n\t\treturn parseVnet(resp.Body)\n\t}\n\n\treturn VirtualNetwork{}, r.statusCodeToError(\"add virtual network\", resp)\n}\n\nfunc (r *RESTClient) ListVirtualNetworks(filter *VnetFilter) ([]*VirtualNetwork, error) {\n\tendpoint := r.baseEndpoints.accountVnets\n\tendpoint.RawQuery = filter.Encode()\n\tresp, err := r.sendRequest(\"GET\", endpoint, nil)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"REST request failed\")\n\t}\n\tdefer resp.Body.Close()","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cfapi/virtual_network.go#L38-L74","documentation":"CreateVirtualNetwork POSTs to the account-level virtual network endpoint; \"REST request failed\" wraps any failure of sendRequest before an HTTP response is obtained. The chained cause explains the real problem (connectivity, TLS, serialization of the NewVirtualNetwork payload). It never indicates an API-level rejection (those come later via statusCodeToError/parseVnet).","triggerScenarios":"Calling RESTClient.CreateVirtualNetwork(newVnet) when the HTTP request cannot be sent: unreachable API host, TLS errors, request timeouts, or failure marshaling the NewVirtualNetwork body.","commonSituations":"`cloudflared tunnel vnet create` run offline or with a stale proxy; API endpoint misconfigured via flags/env; request body serialization issues from a malformed NewVirtualNetwork struct.","solutions":["Verify connectivity: curl https://api.cloudflare.com/client/v4 from the same host.","Inspect the wrapped cause with %+v to identify DNS/TLS/timeout vs marshaling.","Validate the vnet name/comment/IP CIDRs before calling so the request body serializes cleanly.","Retry after confirming the network path and any proxy settings (HTTPS_PROXY) are correct."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"if newVnet.Name == \"\" || newVnet.IPv4CIDRs == nil {\n\treturn errors.New(\"vnet name and CIDRs are required\")\n}","typeGuard":null,"tryCatchPattern":"vnet, err := client.CreateVirtualNetwork(newVnet)\nif err != nil {\n\tlog.Err(err).Msgf(\"create vnet failed: %+v\", err)\n\treturn err\n}","preventionTips":["Validate vnet fields (name, CIDRs) client-side before the POST","Check network/proxy availability in CI before API calls","Retry transient transport failures with backoff"],"tags":["network","rest-api","virtual-network"],"backgroundTag":"http-request-failed","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}