用swagger访问https://localhost:44360/api/ads/1, 得到的结果是 TypeError: Failed to fetch。
一开始以为是后端代码问题,检查了好久,才发现是AdBlockPlus 把它当成广告过滤了。  
 

I have the following routing, which works on invokation /api/demo/info/34.

[Route("api/demo")]
public class Demo : Controller
{
[HttpGet("Info/{x}")]
public JsonResult GetInfos(string x) { ... }
}

Now, I'd like to pass a query string to select the ID, like so: /api/demo/info?x=34. How should I rephrase the attribute for that?

When I tried entering [HttpGet("Info?x={x}")], the error message said that the question mark isn't valid there. I want to resolve it through the attributive approach and routing from the default mapping isn't an option.

----------------------------------------------

All you should need to do is to declare your attribute as:

[HttpGet("Info")]

while keeping the signature of the method as GetInfos(string x). In a GET route, WebAPI picks up all the parameters from the signature, and those which aren't present in the route can be passed as query string arguments as long as the name in the query string matches the name of the parameter.

swagger访问api, TypeError: Failed to fetch的更多相关文章

  1. 【postman】postman测试API报错如下:TypeError: Failed to execute 'fetch' on 'Window': Invalid value 对中文支持不好

    使用postman测试APi的时候,因为系统需要在header部带上登录用户的信息,所以 如下: 然后测试报错如下:TypeError: Failed to execute 'fetch' on 'W ...

  2. Swagger请求报错:TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

    TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body. 如下图 ...

  3. AspNetCore网关集成Swagger访问使用IdentityServer保护的webapi项目

    创建webapi项目 创建四个webapi项目,两个处理业务,一个网关,一个验证中心.四个项目对应的端口如下, ApiGateway:1999 IdentityServer:16690 Service ...

  4. NetCore 3.0 中使用Swagger生成Api说明文档及升级报错原因

    认识Swagger Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参 ...

  5. [转载]关于android SDK安装Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-1.xml出错

    原文地址为:http://blog.csdn.net/springsky_/article/details/7442388 因为入行移动测试,所以很多测试环境的搭建.从中遇到了和这个GG同样的问题.怕 ...

  6. android SDK Manager更新不了,出现错误提示:"Failed to fetch URL..."!

    可以用以下办法解决: 使用SDK Manager更新时出现问题 Failed to fetch URL https://dl-ssl.google.com/android/repository/rep ...

  7. Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-2.xml, reason: Connectio (andriod sdk manager) http://dl-ssl.google.com/android上不去解决方案

    Fetching https://dl-ssl.google.com/android/repository/addons_list-2.xml  Fetched Add-ons List succes ...

  8. 从壹开始前后端分离 [.netCore 填坑 ] 三十四║Swagger:API多版本控制,带来的思考

    前言 大家周二好呀,.net core + Vue 这一系列基本就到这里差不多了,今天我又把整个系列的文章下边的全部评论看了一下(我是不是很负责哈哈),提到的问题基本都解决了,还有一些问题,已经在QQ ...

  9. SpringBoot整合Swagger测试api构建

    @Author:SimpleWu 什么是Swagger? Swagger是什么:THE WORLD'S MOST POPULAR API TOOLING 根据官网的介绍: Swagger Inspec ...

随机推荐

  1. 用Github做一个静态网页(GithubPages)

    一.新建一个仓库(new). 二.命名Repository name为:(名字).github.io(一定要有.github.io). 三.勾选Initialize this repository w ...

  2. curl java 模拟http请求

    curl java 模拟http请求 直接上代码: public static void main(String args[]) throws Exception { String url = &qu ...

  3. netstat 在windows下和Linux下查看网络连接和端口占用

    假设忽然起个服务,告诉我8080端口被占用了,OK,我要去看一下是什么服务正在占用着,能不能杀 先假设我是在Windows下: 第一列: Proto 协议 第二列: 本地地址[ip+端口] 第三列:远 ...

  4. 《剑指offer》第六十七题(把字符串转换成整数)

    // 面试题67:把字符串转换成整数 // 题目:请你写一个函数StrToInt,实现把字符串转换成整数这个功能.当然,不 // 能使用atoi或者其他类似的库函数. #include <ios ...

  5. lua --- 局部变量

    1.block(代码块) --- 一个控制结构.一个函数体.一个chunk   chunck --- 变量被声明的那个文件或者文本串 2.局部变量只在声明的那个block中有效 3.可以使用 do . ...

  6. C#数组维数及不同维数中元素个数的获取

    简单理解有关数组维数的概念: 1.编程中用到的多维的数组,最多也就是二维数组了 2.数组的维数从0开始计算 using System; using System.Collections.Generic ...

  7. 第 8 章 容器网络 - 050 - 创建 overlay 网络

    在 host1 中创建 overlay 网络 ov_net1: docker network create -d overlay ov_net1 -d overlay 指定 driver 为 over ...

  8. 第 4 章 容器 - 029 - 限制容器的 Block IO

    限制容器的 Block IO Block IO 是另一种可以限制容器使用的资源. Block IO 指的是磁盘的读写,docker 可通过设置权重.限制 bps 和 iops 的方式控制容器读写磁盘的 ...

  9. Docker微容器+微服务将颠覆传统的软件架构

    从我的观点看:Docker是一个微容器,一个云计算的微PaaS容器,类似JVM但比其更强大的容器,直接基于Linux内核,支持各种语言,它比VM虚拟机更加轻量,能够在Linux或云计算IaaS等平台上 ...

  10. sql 聚合函数和group by 联合使用

    原文 很多时候单独使用聚合函数的时候觉得很容易,求个平均值,求和,求个数等,但是和分组一起用就有点混淆了,好记性不如烂笔头,所以就记下来以后看看. 常用聚合函数罗列 1 AVG() - 返回平均值 C ...