Setting App prices using Price Point Id (Appstore Connect API) for new Apps

I am building a script to upload new apps to store via fastlane. However, fastlane currently faces issues with setting prices for newly created apps.SO I created ruby scripts to do it manually via api.

First thing I did was to to get price point of my app with help from this appstore documentation. I was able to get the price point for $0USD and I wanted to set it as the price of my app. I used a patch request to this endpoint, however I am unable to do so.

Heres an update of my scripts, If anyone can point me to the right direction.

    lane :setAppPrice do
    auth_token = authAppstoreAPI()
    puts "Token: #{auth_token}"

    app_id = 'app_id_here'
    price_point_id = get_app_price_points(auth_token: auth_token, app_id: app_id)
    

    if price_point_id
        url = URI("https://api.appstoreconnect.apple.com/v1/#{app_id}/appPricePoints/#{price_point_id}")

        # Create the HTTP request for updating the app price
        http = Net::HTTP.new(url.host, url.port)
        http.use_ssl = true

        # Prepare the PATCH request
        headers = {
            "Authorization" => "Bearer #{auth_token}",
            "Content-Type" => "application/json"
        }

        request = Net::HTTP::Patch.new(url, headers)

        # Prepare the body with the new price data
        request.body = {
            data: {
            id: price_point_id,
            type: "appPricePoints",
            attributes: {
                customerPrice: 0.0 # Set your desired new price here
            }
            }
        }.to_json

        # Execute the request
        response = http.request(request)

        # Handle the response
        if response.code == "200"
            UI.success("Successfully updated app price to 0.0 for price point ID #{price_point_id}")
        else
            UI.error("Failed to update app price: #{response.body}")
        end
    end
  end

  lane :get_app_price_points do |options|

    require 'json'
    require 'net/http'
  
    auth_token = options[:auth_token]  # Your App Store Connect API token
    app_id = options[:app_id]          # The app ID for which you want to list subscriptions
  
    # Define the URL for fetching subscriptions
    url = URI("https://api.appstoreconnect.apple.com/v1/apps/#{app_id}/appPricePoints?filter%5Bterritory%5D=USA,CAN&include=territory")
  
    # Create the HTTP request
    http = Net::HTTP.new(url.host, url.port)
    http.use_ssl = true
  
    # Set up headers for the App Store Connect API request
    headers = {
      "Authorization" => "Bearer #{auth_token}",
      "Content-Type" => "application/json"
    }
  
    # Prepare the GET request
    request = Net::HTTP::Get.new(url, headers)
  
    # Execute the request
    response = http.request(request)
  
    # Handle the response
    if response.code == "200"
        app_prices = JSON.parse(response.body)
        # UI.message("Subscriptions for app #{app_id}: #{response.body}")

        # Use the find method to get the free price point ID directly
        free_price_point = app_prices["data"].find do |price_point|
            price_point["attributes"]["customerPrice"] == "0.0"
        end

        free_price_point_id = free_price_point ? free_price_point["id"] : nil
        UI.message("Free Price Point ID: #{free_price_point_id}")

        # Return the ID of the price point with 0.0 price
        free_price_point_id
    else
      UI.error("Failed to fetch subscriptions: #{response.body}")
    end
  end

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật