admin管理员组

文章数量:1418080

I want to update the prices in all territories of an auto-renewable subscription at once (in a single request). I know it's possible to do it territory by territory using the Create a Subscription Price Change API endpoint, but this means I need to call this API for every territory. And I have a lot of subscriptions I need to update.

There is an another API endpoint that seems to allow to Modify an Auto-Renewable Subscription.

For the countries where I want to change the price, I fetch the subscription price points using the List All Price Points for a Subscription API endpoint.

When I call this API endpoint with the following body (that is the expected body content for this endpoint):

{
  "data": {
    "type": "subscriptions",
    "relationships": {
      "prices": {
        "data": [
          {
            "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJDQU4iLCJwIjoiMTAwMDEifQ",
            "type": "subscriptionPrices"
          },
          {
            "type": "subscriptionPrices",
            "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJVU0EiLCJwIjoiMTAwMDEifQ"
          }
        ]
      }
    },
    "id": "6740021496"
  },
  "included": [
    {
      "relationships": {
        "subscriptionPricePoint": {
          "data": {
            "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJDQU4iLCJwIjoiMTAwMDEifQ",
            "type": "subscriptionPricePoints"
          }
        },
        "territory": {
          "data": {
            "type": "territories",
            "id": "CAN"
          }
        },
        "subscription": {
          "data": {
            "id": "6740021496",
            "type": "subscriptions"
          }
        }
      },
      "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJDQU4iLCJwIjoiMTAwMDEifQ",
      "attributes": {
        "preserveCurrentPrice": true
      },
      "type": "subscriptionPrices"
    },
    {
      "attributes": {
        "preserveCurrentPrice": true
      },
      "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJVU0EiLCJwIjoiMTAwMDEifQ",
      "type": "subscriptionPrices",
      "relationships": {
        "subscription": {
          "data": {
            "type": "subscriptions",
            "id": "6740021496"
          }
        },
        "subscriptionPricePoint": {
          "data": {
            "type": "subscriptionPricePoints",
            "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJVU0EiLCJwIjoiMTAwMDEifQ"
          }
        },
        "territory": {
          "data": {
            "type": "territories",
            "id": "USA"
          }
        }
      }
    }
  ]
}

I receive a 409 error:

{
  "errors" : [ {
    "id" : "5b6a4b62-686c-4a65-87ba-e16131db517b",
    "status" : "409",
    "code" : "ENTITY_ERROR",
    "title" : "There is a problem with the request entity",
    "detail" : "User is not allowed to edit.",
    "source" : {
      "pointer" : "subscriptionPrices"
    }
  } ]
}

I made sure

  • my bearer authorisation token is correct and still valid (not expired).
  • the p8 key has Admin rights

Can this PATCH endpoint be used for what I want to do? If yes, is there anything special to do to use this PATCH endpoint?

Thanks

I want to update the prices in all territories of an auto-renewable subscription at once (in a single request). I know it's possible to do it territory by territory using the Create a Subscription Price Change API endpoint, but this means I need to call this API for every territory. And I have a lot of subscriptions I need to update.

There is an another API endpoint that seems to allow to Modify an Auto-Renewable Subscription.

For the countries where I want to change the price, I fetch the subscription price points using the List All Price Points for a Subscription API endpoint.

When I call this API endpoint with the following body (that is the expected body content for this endpoint):

{
  "data": {
    "type": "subscriptions",
    "relationships": {
      "prices": {
        "data": [
          {
            "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJDQU4iLCJwIjoiMTAwMDEifQ",
            "type": "subscriptionPrices"
          },
          {
            "type": "subscriptionPrices",
            "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJVU0EiLCJwIjoiMTAwMDEifQ"
          }
        ]
      }
    },
    "id": "6740021496"
  },
  "included": [
    {
      "relationships": {
        "subscriptionPricePoint": {
          "data": {
            "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJDQU4iLCJwIjoiMTAwMDEifQ",
            "type": "subscriptionPricePoints"
          }
        },
        "territory": {
          "data": {
            "type": "territories",
            "id": "CAN"
          }
        },
        "subscription": {
          "data": {
            "id": "6740021496",
            "type": "subscriptions"
          }
        }
      },
      "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJDQU4iLCJwIjoiMTAwMDEifQ",
      "attributes": {
        "preserveCurrentPrice": true
      },
      "type": "subscriptionPrices"
    },
    {
      "attributes": {
        "preserveCurrentPrice": true
      },
      "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJVU0EiLCJwIjoiMTAwMDEifQ",
      "type": "subscriptionPrices",
      "relationships": {
        "subscription": {
          "data": {
            "type": "subscriptions",
            "id": "6740021496"
          }
        },
        "subscriptionPricePoint": {
          "data": {
            "type": "subscriptionPricePoints",
            "id": "eyJzIjoiNjc0MDAyMTQ5NiIsInQiOiJVU0EiLCJwIjoiMTAwMDEifQ"
          }
        },
        "territory": {
          "data": {
            "type": "territories",
            "id": "USA"
          }
        }
      }
    }
  ]
}

I receive a 409 error:

{
  "errors" : [ {
    "id" : "5b6a4b62-686c-4a65-87ba-e16131db517b",
    "status" : "409",
    "code" : "ENTITY_ERROR",
    "title" : "There is a problem with the request entity",
    "detail" : "User is not allowed to edit.",
    "source" : {
      "pointer" : "subscriptionPrices"
    }
  } ]
}

I made sure

  • my bearer authorisation token is correct and still valid (not expired).
  • the p8 key has Admin rights

Can this PATCH endpoint be used for what I want to do? If yes, is there anything special to do to use this PATCH endpoint?

Thanks

Share Improve this question asked Jan 29 at 19:05 alpennecalpennec 2,1043 gold badges21 silver badges29 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I just realised it's now working as expected. I noticed my subscription was "In Review" and is now in "Developer Action Needed". Maybe the price cannot be updated while the subscription is "In Review".

本文标签: