title: Integrating Sagepay (Opayo) with Django - How to create a merchant session key
body: <p>I am trying to integrate Opayo (SagePay) with Django and I am having problems generation the merchant session key (MSK).</p>
  <p>From sagepays docs they say to use the below curl request and that I should receive the key in the response</p>
  <pre><code>curl https://pi-test.sagepay.com/api/v1/merchant-session-keys \
  -H &quot;Authorization: Basic aEpZeHN3N0hMYmo0MGNCOHVkRVM4Q0RSRkxodUo4RzU0TzZyRHBVWHZFNmhZRHJyaWE6bzJpSFNyRnliWU1acG1XT1FNdWhzWFA1MlY0ZkJ0cHVTRHNocktEU1dzQlkxT2lONmh3ZDlLYjEyejRqNVVzNXU=&quot;  \
  -H &quot;Content-type: application/json&quot; \
  -X POST \
  -d '{
    &quot;vendorName&quot;: &quot;sandbox&quot;
  }'
  </code></pre>
  <p>I have tried to implement this in my Django view with the following code but I receive a 422 response (Unprocessable Entity response).</p>
  <pre><code>import requests
  
  def BasketView(request): 
      headers = {
          &quot;Authorization&quot;: &quot;Basic aEpZeHN3N0hMYmo0MGNCOHVkRVM4Q0RSRkxodUo4RzU0TzZyRHBVWHZFNmhZRHJyaWE6bzJpSFNyRnliWU1acG1XT1FNdWhzWFA1MlY0ZkJ0cHVTRHNocktEU1dzQlkxT2lONmh3ZDlLYjEyejRqNVVzNXU=&quot;,
          &quot;Content-type&quot;: &quot;application/json&quot;,
      }
      data = {&quot;vendorName&quot;: &quot;sandbox&quot;}
  
      r = requests.post(&quot;https://pi-test.sagepay.com/api/v1/merchant-session-keys&quot;, headers=headers, params=data)
      print(r)
  
  </code></pre>
  <p>Any ideas where I may be going wrong with this?</p>