Skip to content

Instantly share code, notes, and snippets.

@cwickham
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save cwickham/755bab94c329a9ec6a10 to your computer and use it in GitHub Desktop.

Select an option

Save cwickham/755bab94c329a9ec6a10 to your computer and use it in GitHub Desktop.
> PUT("https://canvas.instructure.com/api/v1/courses/890522/pages/my-new-page",
+ body = list("wiki_page[body]"= paste(readLines("test-simple.html"), collapse = "\n")),
+ add_headers("Authorization" = paste0("Bearer ", token)), verbose())
-> PUT /api/v1/courses/890522/pages/my-new-page HTTP/1.1
-> User-Agent: curl/7.30.0 Rcurl/1.95.4.1 httr/0.4.0.99
-> Host: canvas.instructure.com
-> Accept: */*
-> Accept-Encoding: gzip
-> Cookie: _csrf_token=R%2FAKhdtpkRA0HlWiFs4W%2B%2Bmu77rW7bM9XuUsvOa%2Bvc0Q32Hs7gzrYx9WfvRDjHK0i8yAzr7Y8FMo0WDQ05Xyuw%3D%3D; canvas_session=TPgoJzbRWborci-ryiUD9A.YcHtPu1gIj92ifvQL5cJY0A7GSoRD1VKXyuwQDR2dbsXl-LG-wsDyqYnpJ2wkOS-sjEfLPPpwT3i7lw-tsWa5mS4jMyVQROjcas_0ojuypKooSlaRrVmh8pofrfnLBZBh6iaPzTjeiVkzOZe3W1bXw.AU-3cNhCsO3pM8yv5mNNw22tBtg.VEVt-g
-> Authorization: Bearer 7~lzo8qNB80Ta0D6oq3tGVW9TzFs5MXbnA3FmEOIHzbQ5U2nOzuFV7n7TEq9dCpCPg
-> Content-Length: 289
-> Expect: 100-continue
-> Content-Type: multipart/form-data; boundary=----------------------------b229a0f90df0
->
<- HTTP/1.1 100 Continue
>> ------------------------------b229a0f90df0
>> Content-Disposition: form-data; name="wiki_page[body]"
>>
>> <h1>a heading</h1>
>>
>> <p>Note that the parameter was added to the code chunk to prevent printing of the R code that generated the plot.</p>
>> ------------------------------b229a0f90df0--
<- HTTP/1.1 200 OK
<- Cache-Control: max-age=0, private, must-revalidate
<- Content-Encoding: gzip
<- Content-Type: application/json; charset=utf-8
<- Date: Mon, 20 Oct 2014 20:21:14 GMT
<- ETag: "37c107938eec66deef3a4720b97bf91a"
<- P3P: CP="None, see http://www.instructure.com/privacy-policy"
<- Server: Apache
<- Set-Cookie: _csrf_token=yy76lfVv5sjQctxc2vhs7P42bmUXdDgML1bb6kK3m2ecAZH8wAqcu%2Fs69wqPugijnFQBEX9Be2JZYpeGd5zUEQ%3D%3D; path=/
<- Status: 200
<- Vary: Accept-Encoding
<- X-Canvas-Meta: a=10;g=ff2e5780-fa5b-012d-f7b3-123135003972;s=7;c=cluster7;z=us-east-1b;o=wiki_pages_api;n=update;x=5;p=t;t=Course;i=890522;e=60593834;b=715092;m=714964;u=0.11;y=0.01;d=0.07;
<- X-Canvas-User-Id: 70000004219152
<- X-Frame-Options: SAMEORIGIN
<- X-Rack-Cache: invalidate, pass
<- X-Request-Context-Id: 9067ca20-3ac4-0132-a927-0a60dd4d3369
<- X-Runtime: 0.240834
<- X-Session-Id: bf08075eb2fbf714bf9d00c509744ed2
<- X-UA-Compatible: IE=Edge,chrome=1
<- Content-Length: 464
<- Connection: keep-alive
<-
Response [https://canvas.instructure.com/api/v1/courses/890522/pages/my-new-page]
Date: 2014-10-20 13:21
Status: 200
Content-type: application/json; charset=utf-8
Size: 775 B
Warning message:
In readLines("test-simple.html") :
incomplete final line found on 'test-simple.html'
> PUT("https://canvas.instructure.com/api/v1/courses/890522/pages/my-new-page",
+ body = list("wiki_page[body]"= upload_file("test-simple.html", type = "text/plain")),
+ add_headers("Authorization" = paste0("Bearer ", token)), verbose())
-> PUT /api/v1/courses/890522/pages/my-new-page HTTP/1.1
-> User-Agent: curl/7.30.0 Rcurl/1.95.4.1 httr/0.4.0.99
-> Host: canvas.instructure.com
-> Accept: */*
-> Accept-Encoding: gzip
-> Cookie: _csrf_token=ztadvG9dMb%2FmKVqtOWk971G25le5buh%2Fk621ICY6T9aZ%2BfbVWjhLzM1hcftsK1mgM9SJI9FbqxHlmflMExEAoA%3D%3D; canvas_session=MzPdaRPTXbKi2XTaKnsPLg.z0J1PmMQL6wmuys55jjsVWRAA7K80Iv3GJxCzzGK_zNipFeC3QTfLyKub5CpbYOJ7-Ltj7ib_s301yqBm2YuVjllsPpr0IAGTkQ_EtBPLNM-VlRQvQeMys76voRJ5vpbzaSLhM_Yji1o4xdY4G-ELA.62bi0MGa6WiHKngNYNoUbziEz40.VEVr-g
-> Authorization: Bearer 7~lzo8qNB80Ta0D6oq3tGVW9TzFs5MXbnA3FmEOIHzbQ5U2nOzuFV7n7TEq9dCpCPg
-> Content-Length: 344
-> Expect: 100-continue
-> Content-Type: multipart/form-data; boundary=----------------------------97dbe3c5188b
->
<- HTTP/1.1 100 Continue
>> ------------------------------97dbe3c5188b
>> Content-Disposition: form-data; name="wiki_page[body]"; filename="test-simple.html"
>> Content-Type: text/plain
>>
>> <h1>a heading</h1>
>>
>> <p>Note that the parameter was added to the code chunk to prevent printing of the R code that generated the plot.</p>
>>
>> ------------------------------97dbe3c5188b--
<- HTTP/1.1 500 Internal Server Error
<- Cache-Control: no-cache
<- Content-Encoding: gzip
<- Content-Type: application/json; charset=utf-8
<- Date: Mon, 20 Oct 2014 20:18:01 GMT
<- P3P: CP="None, see http://www.instructure.com/privacy-policy"
<- Server: Apache
<- Set-Cookie: _csrf_token=21nR%2Bx4sxGJTPcYdX%2B02fdhu%2FygGAWQCGrszGklvIV2MdrqSK0m%2BEXh17UsKr1IyugyQXG40J2xsj392fERuKw%3D%3D; path=/
<- Set-Cookie: canvas_session=TPgoJzbRWborci-ryiUD9A.YcHtPu1gIj92ifvQL5cJY0A7GSoRD1VKXyuwQDR2dbsXl-LG-wsDyqYnpJ2wkOS-sjEfLPPpwT3i7lw-tsWa5mS4jMyVQROjcas_0ojuypKooSlaRrVmh8pofrfnLBZBh6iaPzTjeiVkzOZe3W1bXw.AU-3cNhCsO3pM8yv5mNNw22tBtg.VEVt-g; path=/; secure; HttpOnly
<- Status: 500
<- Vary: Accept-Encoding
<- X-Canvas-Meta: a=10;g=ff2e5780-fa5b-012d-f7b3-123135003972;s=7;c=cluster7;z=us-east-1c;b=824128;m=824256;u=0.04;y=0.00;d=0.06;
<- X-Canvas-User-Id: 70000004219152
<- X-Rack-Cache: invalidate, pass
<- X-Request-Context-Id: 1dab4bf0-3ac4-0132-f80a-0ef0a7a8a416
<- X-Runtime: 0.119101
<- X-Session-Id: bf08075eb2fbf714bf9d00c509744ed2
<- X-UA-Compatible: IE=Edge,chrome=1
<- Content-Length: 108
<- Connection: keep-alive
<-
Response [https://canvas.instructure.com/api/v1/courses/890522/pages/my-new-page]
Date: 2014-10-20 13:18
Status: 500
Content-type: application/json; charset=utf-8
Size: 109 B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment