Skip to content

Commit

Permalink
Add content-header to http requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kt474 committed Dec 17, 2024
1 parent c6198f8 commit 3bae07c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions qiskit_ibm_runtime/api/rest/program_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@ def update_tags(self, tags: list) -> Response:
Returns:
API Response.
"""
self.session.headers.update(self._HEADER_JSON_CONTENT)
return self.session.put(self.get_url("tags"), data=json.dumps({"tags": tags}))
1 change: 1 addition & 0 deletions qiskit_ibm_runtime/api/rest/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def login(self, api_token: str) -> Dict[str, Any]:
JSON response.
"""
url = self.get_url("login")
self.session.headers.update(self._HEADER_JSON_CONTENT)
return self.session.post(url, json={"apiToken": api_token}).json()

def user_info(self) -> Dict[str, Any]:
Expand Down
1 change: 1 addition & 0 deletions qiskit_ibm_runtime/api/rest/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def program_run(
if private:
payload["private"] = True
data = json.dumps(payload, cls=RuntimeEncoder)
self.session.headers.update(self._HEADER_JSON_CONTENT)
return self.session.post(url, data=data, timeout=900).json()

def jobs_get(
Expand Down
2 changes: 2 additions & 0 deletions qiskit_ibm_runtime/api/rest/runtime_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def create(
payload["max_session_ttl"] = max_time # type: ignore[assignment]
else:
payload["max_ttl"] = max_time # type: ignore[assignment]
self.session.headers.update(self._HEADER_JSON_CONTENT)
return self.session.post(url, json=payload).json()

def cancel(self) -> None:
Expand All @@ -73,6 +74,7 @@ def close(self) -> None:
"""Set accepting_jobs flag to false, so no more jobs can be submitted."""
payload = {"accepting_jobs": False}
url = self.get_url("self")
self.session.headers.update(self._HEADER_JSON_CONTENT)
try:
self.session.patch(url, json=payload)
except RequestsApiError as ex:
Expand Down

0 comments on commit 3bae07c

Please sign in to comment.