import requests
url = "http://localhost:8080"
data = {'sender': 'Alice', 'receiver': 'Bob', 'message': 'We did it!'}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)

b'<!DOCTYPE html>\n<html class="client-nojs" lang="en" dir="ltr">\n<head>\n<meta charset="UTF-8"/>\n<title>MediaWiki API result - Wikidata</title>\n<script>document.documentElement.className = document.documentElement.className.replace( /(^|\\s)client-nojs(\\s|$)/, "$1client-js$2" );</script>\n<script>(window.RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgCanonicalNamespace":"Special","wgCanonicalSpecialPageName":"ApiHelp","wgNamespaceNumber":-1,"wgPageName":"Special:ApiHelp","wgTitle":"ApiHelp","wgCurRevisionId":0,"wgRevisionId":0,"wgArticleId":0,"wgIsArticle":false,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"Special:ApiHelp","wgRelevantArticleId":0,"wgRequestId":"WuYK0QpAMEMAABwK8MQAAABH","wgIsProbablyEditable":false,"wgRelevantPageIsProbablyEditable":false,"wgCategoryTreePageCategoryOptions":"{\\"mode\\":0,\\"hideprefix\\":20,\\"showcount\\":true,\\"namespaces\\":false}","wgWikiEditorEnabledModules":[],"wgBetaFeaturesFeatures":[],"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en","usePageImages":true,"usePageDescriptions":true},"wgPreferredVariant":"en","wgMFExpandAllSectionsUserOption":true,"wgMFEnableFontChanger":true,"wgMFDisplayWikibaseDescriptions":{"search":true,"nearby":true,"watchlist":true,"tagline":false},"wgULSCurrentAutonym":"English","wgNoticeProject":"wikidata","wgCentralNoticeCookiesToDelete":[],"wgCentralNoticeCategoriesUsingLegacy":["Fundraising","fundraising"],"wgScoreNoteLanguages":{"arabic":"\xd8\xa7\xd9\x84\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a\xd8\xa9","catalan":"catal\xc3\xa0","deutsch":"Deutsch","english":"English","espanol":"espa\xc3\xb1ol","italiano":"italiano","nederlands":"Nederlands","norsk":"norsk","portugues":"portugu\xc3\xaas","suomi":"suomi","svenska":"svenska","vlaams":"West-Vlams"},"wgScoreDefaultNoteLanguage":"nederlands","wgCentralAuthMobileDomain":false,"wgCodeMirrorEnabled":false,"wgVisualEditorToolbarScrollOffset":0,"wgVisualEditorUnsupportedEditParams":["undo","undoafter","veswitched"],"wgEditSubmitButtonLabelPublish":true});mw.loader.state({"ext.globalCssJs.user.styles":"ready","ext.globalCssJs.site.styles":"ready","site.styles":"ready","noscript":"ready","user.styles":"ready","user":"ready","user.options":"ready","user.tokens":"loading","mediawiki.apipretty":"ready","ext.pygments":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.pt":"ready","ext.wikidata-org.badges":"ready","ext.wikimediaBadges":"ready","mediawiki.legacy.shared":"ready","mediawiki.legacy.commonPrint":"ready","mediawiki.sectionAnchor":"ready","mediawiki.skinning.interface":"ready","ext.globalCssJs.user":"ready","ext.globalCssJs.site":"ready"});mw.loader.implement("user.tokens@0jw61wu",function($,jQuery,require,module){/*@nomin*/mw.user.tokens.set({"editToken":"+\\\\","patrolToken":"+\\\\","watchToken":"+\\\\","csrfToken":"+\\\\"});\n});mw.loader.load(["site","mediawiki.page.startup","mediawiki.user","mediawiki.hidpi","mediawiki.page.ready","mediawiki.searchSuggest","wikibase.ui.entitysearch","ext.gadget.Search","ext.gadget.AuthorityControl","ext.gadget.CommonsMedia","ext.gadget.SiteIdToInterwiki","ext.gadget.ProtectionIndicators","ext.gadget.PopupsFix","ext.gadget.imagelinks","ext.gadget.NewSection","ext.gadget.formWizard","ext.centralauth.centralautologin","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.eventLogging.subscriber","ext.wikimediaEvents","ext.navigationTiming","ext.uls.eventlogger","ext.uls.init","ext.uls.compactlinks","ext.uls.interface","ext.3d","ext.centralNotice.geoIP"]);});</script>\n<link rel="stylesheet" href="/w/load.php?debug=false&amp;lang=en&amp;modules=ext.pygments%2CwikimediaBadges%7Cext.uls.pt%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikidata-org.badges%7Cmediawiki.apipretty%2CsectionAnchor%7Cmediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.skinning.interface&amp;only=styles&amp;skin=apioutput"/>\n<script async="" src="/w/load.php?debug=false&amp;lang=en&amp;modules=startup&amp;only=scripts&amp;skin=apioutput"></script>\n<meta name="ResourceLoaderDynamicStyles" content=""/>\n<link rel="stylesheet" href="/w/load.php?debug=false&amp;lang=en&amp;modules=site.styles&amp;only=styles&amp;skin=apioutput"/>\n<meta name="generator" content="MediaWiki 1.32.0-wmf.1"/>\n<meta name="referrer" content="origin"/>\n<meta name="referrer" content="origin-when-crossorigin"/>\n<meta name="referrer" content="origin-when-cross-origin"/>\n<link rel="apple-touch-icon" href="/static/apple-touch/wikidata.png"/>\n<link rel="shortcut icon" href="/static/favicon/wikidata.ico"/>\n<link rel="search" type="application/opensearchdescription+xml" href="/w/opensearch_desc.php" title="Wikidata (en)"/>\n<link rel="EditURI" type="application/rsd+xml" href="//www.wikidata.org/w/api.php?action=rsd"/>\n<link rel="license" href="/wiki/Wikidata:Copyright"/>\n<link rel="alternate" type="application/atom+xml" title="Wikidata Atom feed" href="/w/index.php?title=Special:RecentChanges&amp;feed=atom"/>\n<link rel="canonical" href="https://www.wikidata.org/wiki/Special:ApiHelp"/>\n<link rel="dns-prefetch" href="//login.wikimedia.org"/>\n<!--[if lt IE 9]><script src="/w/load.php?debug=false&amp;lang=en&amp;modules=html5shiv&amp;only=scripts&amp;skin=vector&amp;sync=1"></script><![endif]-->\n</head>\n<body class="mediawiki ltr sitedir-ltr mw-hide-empty-elt ns--1 ns-special mw-special-ApiHelp page-Special_ApiHelp rootpage-Special_ApiHelp skin-apioutput action-view">\n\t\t<div class="mw-body" role="main">\n\t\t\t<h1 class="firstHeading">MediaWiki API result</h1>\n\t\t\t<div class="mw-body-content">\n\t\t\t\t<div id="mw-content-text"><div class="api-pretty-header"><p>This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.\n</p><p>Specify the <var>format</var> parameter to change the output format. To see the non-HTML representation of the JSON format, set <a class="external text" href="https://www.wikidata.org/w/api.php?action=query&amp;meta=tokens&amp;format=json"><kbd>format=json</kbd></a>.\n</p><p>See the <a href="https://www.mediawiki.org/wiki/API" class="extiw" title="mw:API">complete documentation</a>, or the <a href="/w/api.php?action=help&amp;modules=main">API help</a> for more information.\n</p></div><div dir="ltr"><div class="mw-highlight"><pre><span></span><span class="p">{</span>\n    <span class="s2">&quot;batchcomplete&quot;</span><span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>\n    <span class="s2">&quot;query&quot;</span><span class="o">:</span> <span class="p">{</span>\n        <span class="s2">&quot;tokens&quot;</span><span class="o">:</span> <span class="p">{</span>\n            <span class="s2">&quot;csrftoken&quot;</span><span class="o">:</span> <span class="s2">&quot;+\\\\&quot;</span>\n        <span class="p">}</span>\n    <span class="p">}</span>\n<span class="p">}</span>\n</pre></div>\n</div><noscript><img src="//www.wikidata.org/wiki/Special:CentralAutoLogin/start?type=1x1" alt="" title="" width="1" height="1" style="border: none; position: absolute;" /></noscript></div><div class="printfooter">\nRetrieved from "<a dir="ltr" href="https://www.wikidata.org/wiki/Special:ApiHelp">https://www.wikidata.org/wiki/Special:ApiHelp</a>"</div>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<script>(window.RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgBackendResponseTime":61,"wgHostname":"mw1232"});});</script>\t\t</body></html>\n'
#in the sandbox in Wikipedia it works with edit and my token (automatically corrected https://en.wikipedia.org/wiki/Special:ApiSandbox#action=edit&format=json&title=Talk%3Atest&section=new&text=Hello%20everyone!&summary=Hello%20World&basetimestamp=2008-03-20T17%3A26%3A39.000Z&watchlist=watch&token=c59230033ddcb75c7f9c55bf1d1d28b05ae61ed0%2B%5C)
# Tested in the sandbox https://www.wikidata.org/wiki/Special:ApiSandbox#action=edit&format=json&title=User_talk%3ACriscod&section=new&text=hello&token=4e32842de9e2bcc5ed9883d8d902437a5ae620db%2B%5C
https://www.wikidata.org/w/api.php?action=edit&format=json&title=User_talk%3ACriscod&section=new&text=hello&token=4e32842de9e2bcc5ed9883d8d902437a5ae620db%2B%5C
url='https://www.wikidata.org/w/api.php?action=login&lgname=user&lgpassword=password '
#00eaf0968e22f6c021ff3989c4c76bdb5ae60d3a+\\
# encoded
#00eaf0968e22f6c021ff3989c4c76bdb5ae60d3a%2B%5C%5C

# +\
# %2B%5C

#url = 'https://www.wikidata.org/w/api.php?action=edit&title=User:Criscod&section=new&text=Hello%20everyone!&token=%2B%5C'
url='https://www.wikidata.org/w/api.php?action=edit&format=json&title=User_talk%3ACriscod&section=new&text=hello4&token=4e32842de9e2bcc5ed9883d8d902437a5ae620db%2B%5C'
response = requests.get(url=url)

print(response)
if response.status_code== 200:
    print('hoorray')
   
<Response [200]>
hoorray
url = 'https://www.wikidata.org/w/api.php?action=edit&title=Q4115189&summary=editing_sandbox&contentformat=application/json&contentmodel=wikibase-property'

headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url=url, data = {'https://www.wikidata.org/entity/Property:P31':'https://www.wikidata.org/entity/Q515'}, headers=headers)

#api.php?action=edit&title=Talk:Main_Page&section=new&summary=Hello%20World&text=Hello%20everyone!&watchlist=watch&basetimestamp=2008-03-20T17:26:39Z&token=cecded1f35005d22904a35cc7b736e18%2B%5C
print(response)
if response.status_code== 200:
    print('hoorray')
    #data = response.json()

    #querydata = data['query']
    #firstcontribution = querydata["usercontribs"][0]
   
<Response [200]>
hoorray
'api.php?action=edit&title=Q4115189&summary=editing_sandbox&contentformat=application/json': No schema supplied. 
    Perhaps you meant http://api.php?action=edit&title=Q4115189&summary=editing_sandbox&contentformat=application/json?