I'm trying to upload a file:
curl -X PUT -u "my_username:pass123" "https://nextcloud.my_domain.com/remote.php/webdav/Shared/dir1/" --data-binary #"/Users/user1/test1.png"
Error:
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre\DAV\Exception\Conflict</s:exception>
<s:message>PUT is not allowed on non-files.</s:message>
</d:error>
Why?
The credentials I'm using are the ones I use for login in the browser.
The PUT request needs to refer to the actual file you want to create, right now you are pointing to a directory.
So instead of:
https://nextcloud.my_domain.com/remote.php/webdav/Shared/dir1/
Use:
https://nextcloud.my_domain.com/remote.php/webdav/Shared/dir1/test1.png
Related
We have a (public) Google Cloud Storage bucket that hosts a simple website, meaning both HTML and images.
Our build process uses Google Cloud Build, however the question is not tied to using Cloud Build, but specifically regarding on how to use gsutil properly.
This is our current gsutil task:
# Upload it to the bucket
- name: gcr.io/cloud-builders/gsutil
dir: "public/"
args: [
"-m", # run the rsync command in parallel
"-h", "Cache-Control: public, max-age=0", # Custom cache control header
"cp", # copy command
"-r", # recursively
".", # source folder
"gs://mybucket/" # the target bucket and folder
]
As you can see, this copies everything in the local public/ folder to the bucket and applies the Cache-Control header on all objects.
According to this:
https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata
You can specify the content type with
-h "Content-Type:text/html; charset=utf-8"
However, this makes all objects (not only .html files, but also images, etc) to get the content type text/html; charset=utf-8.
(I have even tried -h "Content-Type:; charset=utf-8" but then gsutil fails saying its an invalid content type value).
Is there a way to tell gsutil to apply charset=utf-8 on all objects, without actually overwriting the main content type?
I am trying to upload a file to a rest server from jenkins using http plugin. I have a jenkins pipelie where a step involves loading a file(type formData)
to a server using rest.
the server side method uses two parameters:
(#FormDataParam("file") InputStream file, #FormDataParam("fileName") String fileName)
I am using the below method
def filename = "${WORKSPACE}/Test.txt"
data="""{ \"fileName\" : \"Test.txt\" }"""
resp3 = httpRequest consoleLogResponseBody: true,url: "http://<url>",contentType:'APPLICATION_OCTETSTREAM',customHeaders:[[name:'Authorization', value:"Basic ${auth}"]],httpMode: 'POST',multipartName: 'Test.txt',uploadFile: "${filename}",requestBody:data,validResponseCodes: '200'
but when I run the status code is 400 and in the server logs the message is that no filestream and no filename is received i.e not able to get both the arguments.
Please let me know where it is getting wrong
Regards
You can try using curl instead of built-in Jenkins methods:
curl -XPOST http://<url> -H 'Content-Type: application/octet-stream' -H 'Authorization: Basic ${auth}' --data-binary '{\"fileName\" : \"Test.txt\" }'
You can debug it first from within shell. Once it's working, wrap it in sh directive:
sh "curl ..."
Since I was running on windows so bat + curl worked for me .With this workaround I was able to transfer files using jenkins and rest
However using httpRequest from jenkins inbuild library is still not working.
I'm using a wiremock standlaone service to mock several json Object.
Actually I want to mock a pdf file: it works fine on my local by just adding my pdf to the __files folder
However I'm trying to use a POSTMAN (or curl) to push the pdf on the server and this doesnt work :
Here is my curl :
curl -X PUT https://wiremock-mock.myserver.com/__admin/files/Hello_World.pdf
-H 'Accept: */*'-H 'content-type: multipart/form-data'
-F pdf=#///usr/Perso/Downloads/Hello_World.pdf
I'm getting this error:
HTTP ERROR 500
Problem accessing /api/test/fichiers/111111. Reason:
Server Error
Caused by:
wiremock.com.github.jknack.handlebars.HandlebarsException: inline#7adccef6:30:88: found: '?'
#???8FV?c?M8?+?J-P??????????GY???(|?6M:#????w]t???2?P?o?si????2??u?yD]F??$p?
?a????{{z???Z????q????5D&????j}??
??i?s??????{*?r?)5??ee???gzZ?-??kh?'??``Av?2?????(?????Q[????>yYn??iy???vj?f2O?u???gK_???#?7!?c??WF?Y??3$?u ?tT?k)???>??YE???0eX|?V?>?n?-????=?>??j?vB??;?????}2??e?mS?c?D?az??,^?ahV???^??G??R?????\??2?oTjD???G???3??|??9????vnz???&????????M??~?b???????????0???i[v?]?e?"????_????H1m??I?~à;?=???K?.????Ws???? c[?zW9?????]?E:,???????[?^?:????=?????9??V?DF??8?C??+"g$????J??\?nJ?
?Q??n?/?y?????NY?|??????L??3{??c??`C??????N??l??e?????-A??r?4??%???~i?-?????????9ZT!K?i?6)5R???1.????4??6????? B?k2Z????P?6!$??????GFQ????ur?(??(??G?z???d??(????*???J??U??
?R"?b??I?Q?#?? mt??2d??= ????\?6??kO
^
at wiremock.com.github.jknack.handlebars.internal.HbsErrorReporter.syntaxError(HbsErrorReporter.java:93)
at wiremock.org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
at wiremock.com.github.jknack.handlebars.internal.HbsParserFactory$2.notifyListeners(HbsParserFactory.java:148)
at wiremock.org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:144)
at wiremock.org.antlr.v4.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:169)
at wiremock.org.antlr.v4.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:152)
at wiremock.org.antlr.v4.runtime.BufferedTokenStream.consume(BufferedTokenStream.java:136)
at wiremock.org.antlr.v4.runtime.Parser.consume(Parser.java:571)
at wiremock.org.antlr.v4.runtime.Parser.match(Parser.java:203)
at wiremock.com.github.jknack.handlebars.internal.HbsParser.sexpr(HbsParser.java:887)
at wiremock.com.github.jknack.handlebars.internal.HbsParser.var(HbsParser.java:1381)
at wiremock.com.github.jknack.handlebars.internal.HbsParser.statement(HbsParser.java:344)
at wiremock.com.github.jknack.handlebars.internal.HbsParser.body(HbsParser.java:222)
at wiremock.com.github.jknack.handlebars.internal.HbsParser.template(HbsParser.java:165)
at wiremock.com.github.jknack.handlebars.internal.HbsParserFactory$1.parse(HbsParserFactory.java:84)
at wiremock.com.github.jknack.handlebars.cache.NullTemplateCache.get(NullTemplateCache.java:54)
at wiremock.com.github.jknack.handlebars.Handlebars.compile(Handlebars.java:475)
at wiremock.com.github.jknack.handlebars.Handlebars.compileInline(Handlebars.java:435)
at wiremock.com.github.jknack.handlebars.Handlebars.compileInline(Handlebars.java:415)
at com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer.uncheckedCompileTemplate(ResponseTemplateTransformer.java:168)
at com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer.transform(ResponseTemplateTransformer.java:122)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.applyTransformations(InMemoryStubMappings.java:91)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:72)
at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:167)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:50)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:47)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:108)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at wiremock.org.eclipse.jetty.servlets.gzip.GzipHandler.handle(GzipHandler.java:479)
at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at wiremock.org.eclipse.jetty.server.Server.handle(Server.java:499)
at wiremock.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at wiremock.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)
at wiremock.org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:748)
How may I push a pdf file on the wiremock server ?
As mentioned in frisby official document (http://frisbyjs.com/) , I am using --junitreport something like following
jasmine-node ./demo/validation_spec.js/ --junitreport --output
C:\Users\Administrator\Documents\script/Reports
which is generating 15 xml files. As I am calling 15 time post using for loop. File contains data like following
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites>
<testsuite name="Frisby Test:blank action " errors="0" tests="1" failures="0" time="0.284" timestamp="2017-03-21T13:55:15">
<testcase classname="Frisby Test: blank action " name="
[ POST https://localhost:8443/api/v2/settings/pointwise ]" time="0.282"></testcase>
</testsuite>
</testsuites>
so my difficulty is that I need to read each and every file to check if tests is pass or not. I want some kind of overview page like http://maven.apache.org/surefire/maven-surefire-report-plugin/surefire-report.html
which contain information how many test passed, fail etc. Is it possible to get that.
I am sending the following curl command from terminal in Mac OSX:
curl -d "OPERATION_NAME=ADD_REQUEST&TECHNICIAN_KEY=1AD….4&INPUT_DATA=TestData.xml" http://xxx.xx.xx.xx/sdpapi/request/
I am getting back the response:
FailedError when performing - ADD_REQUEST - Content is not allowed in prolog.
Here is my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Operation>
<Details>
<requester>Me</requester>
<subject>Test</subject>
<description>Testing curl input</description>
</Details>
</Operation>
I have checked and my xml file is indeed a UTF-8 file. I can tell from google searches that this most likely has to do with my encoding, however, I can't find how to fix it.
I've also tried saving the xml file as ANSI on my pc, xml file looks like this:
<?xml version="1.0"?>
<Operation>
<Details>
<requester>Me</requester>
<subject>Test</subject>
<description>Testing curl input</description>
</Details>
</Operation>
I downloaded Notepad++ and checked the encoding, which is UTF8 with no BOM.
I am still getting the same error. Can anyone see what I am doing wrong?
Updated 9/19 to add:
In addition to everything I've tried in the comments below, I've also tried this:
curl -d "OPERATION_NAME=ADD_REQUEST&TECHNICIAN_KEY=xxxxxxxxxxxxxxxxx&INPUT_DATA=<?xml version="1.0" encoding="utf-8"?><Operation><Details><requester>Me</requester><subject>Test</subject><description>Testing curl input</description></Details></Operation>" http://xxx.xx.xx.xx/sdpapi/request/
The error I'm getting now is: "Error when performing - ADD_REQUEST - The value following "version" in the XML declaration must be a quoted string."
Anyone have any thoughts?
I replaced <?xml version="1.0" encoding="utf-8"?> with <?xml version=%221.0%22 encoding=%22utf-8%22?>
It is now working.