用存储的REST调用也是401错误~~

我按照教程使用REST调用BLOB的内容,也遇到的是401错误,这是什么情况?还有人也遇到了吗?

1个回答

您好,
请问您使用的是REST中的哪一个方法?据我所知,如果使用REST去调用blob中内容是,复杂的地方主要是在构造签名,首先我建议您先阅读下这篇文档:
https://msdn.microsoft.com/zh-cn/library/azure/dd179428.aspx
例如该方法:

 public void PutBlob(String containerName, String blobName)

{

    String requestMethod = "PUT";



    String urlPath = String.Format("{0}/{1}", containerName, blobName);



    String storageServiceVersion = "2012-02-12";



    String dateInRfc1123Format = DateTime.UtcNow.ToString("R", CultureInfo.InvariantCulture);



    String content = "Andrew Carnegie was born in Dunfermline";

    UTF8Encoding utf8Encoding = new UTF8Encoding();

    Byte[] blobContent = utf8Encoding.GetBytes(content);

    Int32 blobLength = blobContent.Length;



    const String blobType = "BlockBlob";



    String canonicalizedHeaders = String.Format(

            "x-ms-blob-type:{0}\nx-ms-date:{1}\nx-ms-version:{2}",

            blobType,

            dateInRfc1123Format,

            storageServiceVersion);

    String canonicalizedResource = String.Format("/{0}/{1}", AzureStorageConstants.Account, urlPath);

    String stringToSign = String.Format(

            "{0}\n\n\n{1}\n\n\n\n\n\n\n\n\n{2}\n{3}",

            requestMethod,

            blobLength,

            canonicalizedHeaders,

            canonicalizedResource);

    String authorizationHeader = Utility.CreateAuthorizationHeader(stringToSign);



    Uri uri = new Uri(AzureStorageConstants.BlobEndPoint + urlPath);

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

    request.Method = requestMethod;

    request.Headers.Add("x-ms-blob-typeobType);

    request.Headers.Add("x-ms-dateteInRfc1123Format);

    request.Headers.Add("x-ms-versionorageServiceVersion);

    request.Headers.Add("AuthorizationthorizationHeader);

    request.ContentLength = blobLength;



    using (Stream requestStream = request.GetRequestStream())

    {

        requestStream.Write(blobContent, 0, blobLength);

    }



    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())

    {

        String ETag = response.Headers["ETag"];

    }

}


我们需要构造出shared key,同时注意header中的各个信息。
处理rest问题和调试rest错误时,我个人建议您可以使用fiddler去troubleshoot您的reqest请求,去解决问题。
同时,建议您参考这个博客:https://convective.wordpress.com/2010/08/18/examples-of-the-windows-azure-storage-services-rest-api/
Regards,
Will
如果您想进一步了解Windows Azure, Windows Azure 官网欢迎您的访问

xuzhoushi01
xuzhoushi01 谢谢,我试下~~
大约 5 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
微服务 rest 调用 问题。。求解决

使用RestTemplate调用服务,报错 1. java.net.UnknownHostException 2. java.net.ConnectException: Connection refused: connect 我的调用方式 @Autowired private RestTemplate rest; rest.getForObject("http://eurkaF1/getData",List.class); 3QQQQQ

前端(浏览器)如何调用 rest api?

我们开发人员可以通过curl命令来调用rest api,可是我们产品的用户肯定需要浏览网页和点击按钮来操作我们的产品啊,所以如果在前端用form表单发送post请求的话,html示例结构如下: ``` <form method="POST" action="/some"> <input name="username"> <button type="submit">提交</button> </form> ``` 当用户点击提交之后,页面肯定会全部刷新,这都是被弃用的多少年前的技术了,目前流行的都是异步刷新,请问怎么代替这种low的方式呢? 难道rest api理念上就只是给开发人员使用的吗?

如何从PHP运行此REST API调用?

<div class="post-text" itemprop="text"> <p>I'm currently building a project based on the Parse.com backend that includes uploading files. Users can upload files and then access a list of these/download them, this all works fine. However, I'm not sure how to implement the command to delete an upload. <a href="https://parse.com/questions/how-can-i-delete-a-file" rel="nofollow">From the Parse.com forums</a> as well as the <a href="https://parse.com/docs/rest#files-deleting" rel="nofollow">Parse support document</a>, the call is:</p> <pre><code>curl -X DELETE \ -H "X-Parse-Application-Id: &lt;YOUR_APPLICATION_ID&gt;" \ -H "X-Parse-Master-Key: &lt;YOUR_MASTER_KEY&gt;" \ https://api.parse.com/1/files/&lt;FILE_NAME&gt; </code></pre> <p>I've had a bit of a look online but the only curl commands I can find to execute commands is curl_setopt. I imagine the above needs to be converted, can anybody help with this or point me in the right direction?</p> <p>So basically I need to be able to press a button on a website (through PHP) and have it run the above command.</p> <p>Thanks in advance</p> </div>

从Go代码调用用Java编写的rest API

<div class="post-text" itemprop="text"> <p>I am newbie to Golang. I am writing a go client, in which I am trying to invoke a bunch of REST APIs in server</p> <p>Which rest clients/libraries should be used for this use case</p> <p>Thanks!</p> </div>

关于dubbox rest服务 cxf 调用时类型转换的错误

这边搭建了一个dubbox rest的服务端,通过浏览器请求返回正常,客户端通过访问webservice,webservice接口实现类中调用dubbox服务,dubbox方法有参数,结果报错如下: Caused by: java.lang.ClassCastException: org.apache.cxf.jaxrs.impl.UriBuilderImpl cannot be cast to org.jboss.resteasy.specimpl.ResteasyUriBuilder at org.jboss.resteasy.client.jaxrs.internal.ClientWebTarget.queryParamNoTemplate(ClientWebTarget.java:287) at org.jboss.resteasy.client.jaxrs.internal.proxy.processors.webtarget.QueryParamProcessor.apply(QueryParamProcessor.java:23) at org.jboss.resteasy.client.jaxrs.internal.proxy.processors.webtarget.QueryParamProcessor.apply(QueryParamProcessor.java:12) at org.jboss.resteasy.client.jaxrs.internal.proxy.processors.AbstractCollectionProcessor.buildIt(AbstractCollectionProcessor.java:76) at org.jboss.resteasy.client.jaxrs.internal.proxy.processors.webtarget.AbstractWebTargetCollectionProcessor.build(AbstractWebTargetCollectionProcessor.java:22) at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.createRequest(ClientInvoker.java:115) at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:101) at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:62) at com.sun.proxy.$Proxy30.sayHello(Unknown Source) at com.alibaba.dubbo.common.bytecode.Wrapper0.invokeMethod(Wrapper0.java) at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46) at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72) at com.alibaba.dubbo.rpc.protocol.AbstractProxyProtocol$2.doInvoke(AbstractProxyProtocol.java:93) at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:144) at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:53) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:48) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:74) at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53) at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:77) at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:227) at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72) at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52) at com.alibaba.dubbo.common.bytecode.proxy0.sayHello(proxy0.java) at com.nssc.dubbox.ws.server.QueryServerImpl.test(QueryServerImpl.java:46) at com.nssc.dubbox.ws.server.QueryServerImpl.doBiz(QueryServerImpl.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:188) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:104) ... 36 more 这是什么原因造成的

Java客户端如何调用rest接口,在参数比较复杂的情况下

在客户端上传文件,list<file>的形式作为一个参数,该如何添加?通过queryparams.add的方式,...下面图片中代码一直在client实例化这一部分就报错。 Jersey的包已经导入![图片](https://img-ask.csdn.net/upload/201708/28/1503890470_410015.jpg)

如何调用rest接口服务,重启spring boot项目?

修改项目properties配置文件,然后调用rest接口服务,达到重启项目让配置文件生效的目的

Android下Rest Api的学习和使用

最近工作需要用到android机器调用Rest api来进行服务器数据的请求和获取,之前没有 接触过Rest这一块的知识,网上也都是一些很简单的例子,学习效果不是很好,不知道 有没有前辈可指点一二的,小弟不甚感激!

java 调用 rest 接口 怎么写请求行的信息?

Rest接口格式:每一个请求通常由三部分组成:请求行、请求报头、请求正文(可选)。 请求样例: Post <basic_uri>/services/ita/login HTTP/1.1 Host: https://<ip>:<port> Accept:application/json;charset=UTF-8;Content-Type:application/json; charset=UTF-8 Accept-Language:zh_CN X-Auth-User:user X-Auth-Key:password 通过下面的代码,我可以设置请求属性。 URL httpurl = new URL(url); HttpURLConnection conn = (HttpURLConnection) httpurl.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setDefaultUseCaches(false); conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8"); conn.setRequestProperty("Content-Length", String.valueOf(xml.length())); conn.setRequestProperty("SOAPAction", ""); conn.setConnectTimeout(60*1000); conn.setReadTimeout(60*1000); conn.setRequestMethod("POST"); 但是怎么在java代码里写请求行:Post <basic_uri>/services/ita/login HTTP/1.1的信息呢?

调用REST服务时出错

<div class="post-text" itemprop="text"> <p>I am facing a strange problem. I am trying to integrate a REST api in phonegap application. When I request the url say <em><code>http://myserver/index.php?m=login</code></em> via a rest client in my browser it works fine. </p> <p>But when I invoke it via jQuery ajax it returns the following error:</p> <blockquote> <p>Warning: include(C:/Domains/my-portal.org/httpdocs/mmode/template/mobile/index.php) [function.include]: failed to open stream: No such file or directory in C:\Domains\my-portal.org\httpdocs\mmode\index.php on line 13 </p><p> Warning: include(C:/Domains/my-portal.org/httpdocs/mmode/template/mobile/index.php) [function.include]: failed to open stream: No such file or directory in C:\Domains\my-portal.org\httpdocs\mmode\index.php on line 13 </p><p> Warning: include() [function.include]: Failed opening 'C:/Domains/myportal.org/httpdocs/mmode/template/mobile/index.php' for inclusion (include_path='.;./includes;./pear;C:\PHP\includes') in C:\Domains\my-portal.org\httpdocs\mmode\index.php on line 13</p> </blockquote> <p>Now the problem is not cross-domain scripting because the response header returns "<code>Access-Control-Allow-Origin: *</code>". And I have also <em>white-listed</em> the domain in cordova settings. </p> <p>Can anyone please guide me what could be the problem here?</p> </div>

401 Unauthorized 错误是什么问题

我用REST API修改Azure的虚拟机数量,为什么总是报这个错~~ Bug吗?

PayPal REST Api错误:响应401 PPConnectionException

<div class="post-text" itemprop="text"> <p>I'm using the PHP PayPal REST API sandbox and getting errors when I do my <code>$payment-&gt;create( $apiContext );</code></p> <p>My Error log reads as:</p> <pre><code> PHP Fatal error: Uncaught exception 'PayPal\\Exception\\PPConnectionException' with message 'Got Http response code 401 when accessing https://api.paypal.com/v1/oauth2/token. Retried 0 times.' in /usr/local/web/servers/domain/guts/paypal_api/vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php:99 Stack trace: #0 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/Auth/OAuthTokenCredential.php(96): PayPal\\Core\\PPHttpConnection-&gt;execute('grant_type=clie...') #1 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/Auth/OAuthTokenCredential.php(76): PayPal\\Auth\\OAuthTokenCredential-&gt;_generateAccessToken(Array) #2 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/Rest/RestHandler.php(56): PayPal\\Auth\\OAuthTokenCredential-&gt;getAccessToken(Array) #3 /usr/local/web/servers/domain/guts/paypal_api/vendor/paypal/sdk-core-php/lib/PayPal/Transport/PPRestCall.php(41): PayPal\\Rest\\RestHandler-&gt;handle(Object(PayPal\\Core\\PPHttpConfig), '{"intent":"sale...', Array) #4 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/A in /usr/local/web/servers/domain/guts/paypal_api/vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php on line 99, referer: http://domain.com/products/basket/verify/ </code></pre> <p>my PayPal.log file shows:</p> <pre><code>PayPal\Core\PPHttpConnection: Connecting to https://api.paypal.com/v1/oauth2/token PayPal\Core\PPHttpConnection: Payload grant_type=client_credentials PayPal\Core\PPHttpConnection: Adding header User-Agent: PayPalSDK/rest-sdk-php 0.6.0 (lang=PHP;v=5.3.3;bit=64;os=Linux_2.6.18-348.6.1.el5;machine=x86_64;openssl=0.9.8e-fips-rhel5;curl=7.15.5) PayPal\Core\PPHttpConnection: Adding header Authorization: Basic QVpteVVCQ3VfdDhlb3QxcGx0UksyUG56Y3NhcXpOeXNIMlNDLXBDbTlUNGVGNDE3OFd1cFBFRmhkTVpnOkVGZ3g4UkNCZUppSkw3NW1JV1FDRFROTVVsanFOLW1fdlFuM3owMzZOZ3EwTUp3RVFwRkNlV0Z0dWhaag== PayPal\Core\PPHttpConnection: Adding header Accept: */* </code></pre> <p>I've tried test cc numbers, cc numbers set up on paypal's sandbox site. I've tried using the credentials in the demo app provided in rest-api-skd-php-master (the demo works btw).</p> <p>I can show you my code though it pretty precisely emulates the test case.</p> <p>The only thing I can think of is that the processing files are buried below www access levels?</p> <p>If you can clean any info from the error logs I'm all ears. If there's more info you need from me I can provide it.</p> </div>

Slim REST API调用错误,没有错误消息(JQuery)

<div class="post-text" itemprop="text"> <p>I tried to make a GET call from a self written API in javascript (JQuery). I get an error but there is no message included. </p> <p>Client code looks like this</p> <pre><code>$(document).ready(function () { $.ajax({ type: "GET", url: "APIURL...", headers: {"Content-Type": "application/json;odata=verbose", "Accept": "application/json;odata=verbose", "crossDomain": "true", "credentials":"include"}, success: function (data) { console.log(data); }, error: function (jqXHR, textStatus, errorThrown) { console.log(textStatus); //output: error console.log(errorThrown); //output: } }); }); </code></pre> <p>Also tested this with another url of a REST Test API <code>https://jsonplaceholder.typicode.com/todos/1</code>. This works fine, it outputs the expected data in the success function. So I think the problem is somewhere in my own API. </p> <p>I made the API with PHP and the <a href="https://www.slimframework.com/" rel="nofollow noreferrer">Slim Framework</a>. Code looks like this</p> <pre><code>$app-&gt;get ( '/test', function ($request, $response) { $data["test"] = "data"; $json = json_encode ( $data ); $response-&gt;write ( $json ); return $response; }); </code></pre> <p>This is the called function from my jquery code. In the browser its output is as expected <code>{"test":"data"}</code></p> <p>The server where my API runs is reachable from the internet. Any solutions or suggestions?</p> </div>

服务到REST服务REST调用从Wordpress到使用Azure AD保护的.NET Web API

<div class="post-text" itemprop="text"> <p>I am currently creating a .NET Core WebAPI secured with Azure AD. (Which is also giving me challenges <a href="https://stackoverflow.com/questions/42667486/service-to-service-authentication-using-azure-ad-and-webapi">see here</a> </p> <p>I want to call this API from a Wordpress website but need to do a headless service-to-service call. So I need to get an access_token from azure ad (using my active directory app) and send this as the Bearer token.</p> <p>I've had a look around for PHP samples but nothing concrete has come up so far, so would be great to get some pointers or samples on this. </p> </div>

在Java中调用Rest API导致不可处理的实体(422)

<div class="post-text" itemprop="text"> <p>I have a rest API build in php. I am calling that in my java application. When parsing data it gives me Unprocessable Entity (422). The same API with the same data is working absolutely fine. but when I deploy my jar on test server it is causing this. I checked JSON and its same as in my local. Below is the sample JSON, incase that will help you to give any direction.</p> <p>Thanks in advance.</p> <pre><code>{"units":[{"position":{"latitude":52.5218136,"longitude":13.432295},"parkingSpaceId":"5bebfc18ec045b36418b4569","capacity":180,"currentWeight":180,"name":"100095 Textil DRK beige","labelId":"100095","properties":{"contactSettings":{"eventNotificationSettings":{"workingTime":{"harborEntered":{"contacts":[]},"forbiddenCountries":{"contacts":[]},"periodOfUsePassed":{"contacts":[]},"mileagePassed":{"contacts":[]},"powercut":{"contacts":[]},"mileageReached":{"contacts":[]},"operatingBehavior":{"contacts":[]},"routines":{"contacts":[]},"vandalism":{"contacts":[]},"unplannedDoorOpening":{"contacts":[]},"malfunction":{"contacts":[]},"relocation":{"contacts":[]},"emptyingUpcoming":{"contacts":[]},"emptyingOverdue":{"contacts":[]},"batteryReplacementUpcoming":{"contacts":[]},"batteryConditionCritical":{"contacts":[]},"global":true},"offTime":{"harborEntered":{"contacts":[]},"forbiddenCountries":{"contacts":[]},"periodOfUsePassed":{"contacts":[]},"mileagePassed":{"contacts":[]},"powercut":{"contacts":[]},"mileageReached":{"contacts":[]},"operatingBehavior":{"contacts":[]},"routines":{"contacts":[]},"vandalism":{"contacts":[]},"unplannedDoorOpening":{"contacts":[]},"malfunction":{"contacts":[]},"relocation":{"contacts":[]},"emptyingUpcoming":{"contacts":[]},"emptyingOverdue":{"contacts":[]},"batteryReplacementUpcoming":{"contacts":[]},"batteryConditionCritical":{"contacts":[]},"global":true}},"global":true},"timeSettings":{"global":true},"parameters":{"global":true},"forbiddenHarbors":{"harbors":[],"global":true},"forbiddenCountries":{"countries":[],"global":true}},"id":"5c0e8126ec045b53168b459b"},{"position":{"latitude":52.5453222,"longitude":13.5642258},"parkingSpaceId":"5bebf65fec045beb4e8b459b","capacity":180,"currentWeight":180,"name":"100162 Textil DRK weiß","labelId":"100162","properties":{"contactSettings":{"eventNotificationSettings":{"workingTime":{"harborEntered":{"contacts":[]},"forbiddenCountries":{"contacts":[]},"periodOfUsePassed":{"contacts":[]},"mileagePassed":{"contacts":[]},"powercut":{"contacts":[]},"mileageReached":{"contacts":[]},"operatingBehavior":{"contacts":[]},"routines":{"contacts":[]},"vandalism":{"contacts":[]},"unplannedDoorOpening":{"contacts":[]},"malfunction":{"contacts":[]},"relocation":{"contacts":[]},"emptyingUpcoming":{"contacts":[]},"emptyingOverdue":{"contacts":[]},"batteryReplacementUpcoming":{"contacts":[]},"batteryConditionCritical":{"contacts":[]},"global":true},"offTime":{"harborEntered":{"contacts":[]},"forbiddenCountries":{"contacts":[]},"periodOfUsePassed":{"contacts":[]},"mileagePassed":{"contacts":[]},"powercut":{"contacts":[]},"mileageReached":{"contacts":[]},"operatingBehavior":{"contacts":[]},"routines":{"contacts":[]},"vandalism":{"contacts":[]},"unplannedDoorOpening":{"contacts":[]},"malfunction":{"contacts":[]},"relocation":{"contacts":[]},"emptyingUpcoming":{"contacts":[]},"emptyingOverdue":{"contacts":[]},"batteryReplacementUpcoming":{"contacts":[]},"batteryConditionCritical":{"contacts":[]},"global":true}},"global":true},"timeSettings":{"global":true},"parameters":{"global":true},"forbiddenHarbors":{"harbors":[],"global":true},"forbiddenCountries":{"countries":[],"global":true}},"id":"5c0e7f7eec045b51168b4576"},{"position":{"latitude":52.5401149,"longitude":13.5671104},"parkingSpaceId":"5bebfff6ec045bf0418b4572","capacity":180,"currentWeight":180,"name":"100340 Textil RETEX HD","labelId":"100340","properties":{"contactSettings":{"eventNotificationSettings":{"workingTime":{"harborEntered":{"contacts":[]},"forbiddenCountries":{"contacts":[]},"periodOfUsePassed":{"contacts":[]},"mileagePassed":{"contacts":[]},"powercut":{"contacts":[]},"mileageReached":{"contacts":[]},"operatingBehavior":{"contacts":[]},"routines":{"contacts":[]},"vandalism":{"contacts":[]},"unplannedDoorOpening":{"contacts":[]},"malfunction":{"contacts":[]},"relocation":{"contacts":[]},"emptyingUpcoming":{"contacts":[]},"emptyingOverdue":{"contacts":[]},"batteryReplacementUpcoming":{"contacts":[]},"batteryConditionCritical":{"contacts":[]},"global":true},"offTime":{"harborEntered":{"contacts":[]},"forbiddenCountries":{"contacts":[]},"periodOfUsePassed":{"contacts":[]},"mileagePassed":{"contacts":[]},"powercut":{"contacts":[]},"mileageReached":{"contacts":[]},"operatingBehavior":{"contacts":[]},"routines":{"contacts":[]},"vandalism":{"contacts":[]},"unplannedDoorOpening":{"contacts":[]},"malfunction":{"contacts":[]},"relocation":{"contacts":[]},"emptyingUpcoming":{"contacts":[]},"emptyingOverdue":{"contacts":[]},"batteryReplacementUpcoming":{"contacts":[]},"batteryConditionCritical":{"contacts":[]},"global":true}},"global":true},"timeSettings":{"global":true},"parameters":{"global":true},"forbiddenHarbors":{"harbors":[],"global":true},"forbiddenCountries":{"countries":[],"global":true}},"id":"5c0e82e4ec045be9148b45af"},{"position":{"latitude":52.4255217,"longitude":13.4827826},"parkingSpaceId":"5bebfc4bec045b2b418b4569","capacity":180,"currentWeight":108,"name":"101386 Textil DRK weiß","labelId":"101386","properties":{"contactSettings":{"eventNotificationSettings":{"workingTime":{"harborEntered":{"contacts":[]},"forbiddenCountries":{"contacts":[]},"periodOfUsePassed":{"contacts":[]},"mileagePassed":{"contacts":[]},"powercut":{"contacts":[]},"mileageReached":{"contacts":[]},"operatingBehavior":{"contacts":[]},"routines":{"contacts":[]},"vandalism":{"contacts":[]},"unplannedDoorOpening":{"contacts":[]},"malfunction":{"contacts":[]},"relocation":{"contacts":[]},"emptyingUpcoming":{"contacts":[]},"emptyingOverdue":{"contacts":[]},"batteryReplacementUpcoming":{"contacts":[]},"batteryConditionCritical":{"contacts":[]},"global":true},"offTime":{"harborEntered":{"contacts":[]},"forbiddenCountries":{"contacts":[]},"periodOfUsePassed":{"contacts":[]},"mileagePassed":{"contacts":[]},"powercut":{"contacts":[]},"mileageReached":{"contacts":[]},"operatingBehavior":{"contacts":[]},"routines":{"contacts":[]},"vandalism":{"contacts":[]},"unplannedDoorOpening":{"contacts":[]},"malfunction":{"contacts":[]},"relocation":{"contacts":[]},"emptyingUpcoming":{"contacts":[]},"emptyingOverdue":{"contacts":[]},"batteryReplacementUpcoming":{"contacts":[]},"batteryConditionCritical":{"contacts":[]},"global":true}},"global":true},"timeSettings":{"global":true},"parameters":{"global":true},"forbiddenHarbors":{"harbors":[],"global":true},"forbiddenCountries":{"countries":[],"global":true}},"id":"5c0e8140ec045b59168b459c"}],"limit":"5"} </code></pre> <p>Java Code:</p> <pre><code>ClientResource resource = getResource( String.format("%s/internal/unitbases?companyId=" + id + "&amp;limit=10", apiPrefix)); try { Units units = resource.get(Units.class); List&lt;Location&gt; locationListForCompany = units.getUnits(); return locationListForCompany; }catch (Exception e) { System.out.println("exception occur: " + e.getMessage()); } </code></pre> </div>

gRPC服务器如何调用REST端点

<div class="post-text" itemprop="text"> <p>I'm currently new to gRPC technology and have been reading up on it.</p> <p>My current understanding is that <code>gRPC</code> is just another protocol just like how <code>REST</code> is one. Now lets say I spin up a gRPC server that I want clients to consume, but in that gRPC server I'd like to be able to get information from outside consumer RESTful Apis, (for example <a href="https://developer.riotgames.com/api-methods/" rel="nofollow noreferrer">https://developer.riotgames.com/api-methods/</a>) is that still possible? </p> </div>

进行Ajax REST调用

<div class="post-text" itemprop="text"> <p>How I can convert the following <code>cURL</code> into an <code>ajax</code> REST call?</p> <pre><code> curl -u "{username}":"{password}" \ -H "content-type: audio/wav" \ --data-binary @"/path/to/file.wav" \ "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize" </code></pre> <p>I added few of it to below ajax call, I do no know how to add the rest of it, specially the part mentioned in <code>-H</code> and <code>--data-binary @</code></p> <pre><code>function restCall() { $.ajax ({ type: "GET", url: "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize", dataType: 'json', username: "xxxx", password: "xxxx", success: function (data){ alert(JSON.stringify(data)); } }); } </code></pre> </div>

REST PUT请求返回GET 500错误,是否合理?

<div class="post-text" itemprop="text"> <p>I am not any kind of RESTful API expert, but I have a simple <code>PUT/DELETE</code> function in an AngularJS app that has been functioning as expected until now. I am trying to work out whether this problem is likely to lie in my app, or in the (php) back-end that is running the endpoint. Other REST services are functioning normally &amp; the server appears to be running fine. </p> <p>This function only ever calls PUT or DELETE, assigned as <code>var method</code>:</p> <pre><code> if (food.favourite === true) { method = "PUT"; console.log("method is " + method) } else if (food.favourite === false) { method = "DELETE"; console.log("method is " + method) } $http({ method: method, url: $scope.URL }).success(function (data, status, headers, config) { console.log(method + " successful") }).error(function (data, status, headers, config) { console.log(method + " not successful") }); </code></pre> <p>I have one <code>$http GET</code> in my app that uses a different endpoint. There is no <code>$http GET</code> pointing to this endpoint anywhere in my app- I have searched extensively. </p> <p>When I trigger the function containing the $http above, the console shows:</p> <pre><code> method is PUT GET http://localhost:8888/api/ext/51/ 500 (Internal Server Error) PUT not successful </code></pre> <p>Why would I be receiving a <code>GET</code> error on an unsuccessful PUT request? Does this point to a problem in my function, or a problem with the endpoint?</p> <p>Thank you for any help in understanding this problem.</p> <hr> <p>Update 1</p> <p>Info from the Network panel: calling the $http function above triggers two simultaneous requests, one 'PUT' and one 'GET'. The 'PUT' returns a 301 code, and the 'GET' returns a 500 server error (which I think is to be expected, as this endpoint is not set up to respond to 'GET', only to 'PUT' and 'DELETE'). </p> <p>So: why would my code be generating two simultaneous requests with different methods?</p> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

C++11:一些微小的变化(新的数据类型、template表达式内的空格、nullptr、std::nullptr_t)

本文介绍一些C++的两个新特性,它们虽然微小,但对你的编程十分重要 一、Template表达式内的空格 C++11标准之前建议在“在两个template表达式的闭符之间放一个空格”的要求已经过时了 例如: vector&lt;list&lt;int&gt; &gt;; //C++11之前 vector&lt;list&lt;int&gt;&gt;; //C++11 二、nullptr ...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

深入剖析Springboot启动原理的底层源码,再也不怕面试官问了!

大家现在应该都对Springboot很熟悉,但是你对他的启动原理了解吗?

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

【阿里P6面经】二本,curd两年,疯狂复习,拿下阿里offer

二本的读者,在老东家不断学习,最后逆袭

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

微软为一人收购一公司?破解索尼程序、写黑客小说,看他彪悍的程序人生!...

作者 | 伍杏玲出品 | CSDN(ID:CSDNnews)格子衬衫、常掉发、双肩包、修电脑、加班多……这些似乎成了大众给程序员的固定标签。近几年流行的“跨界风”开始刷新人们对程序员的...

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

我说我懂多线程,面试官立马给我发了offer

不小心拿了几个offer,有点烦

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

立即提问
相关内容推荐