Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. Ranjicgnr
    3. Posts
    R
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Ranjicgnr

    • RE: {"message":"Invalid Product Type","errorcode":"AB1012","status":false,"data":null}

      @admin
      The full request code and request payload are are added here for further details

      The app is a wpf app.

      public async Task<bool> PlaceEntryOrder(TradingAccount tradingAccount, Position position)
      {
      
          bool result = false;
          string uri = "https://apiconnect.angelone.in/rest/secure/angelbroking/order/v1/placeOrder";
          //string uri = $"https://webhook.site/a6ac03d9-a9bc-4665-9dae-56cc1f2b5c24";
          try
          {
              if (tradingAccount?.IsLoggedIn == true)
              {
                  HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri);
                  httpRequestMessage.Headers.Add("Authorization", "Bearer " + tradingAccount?.JwtToken);
                  httpRequestMessage.Headers.Add("Accept", "application/json");
                  httpRequestMessage.Headers.Add("X-UserType", "USER");
                  httpRequestMessage.Headers.Add("X-SourceID", "WEB");
                  httpRequestMessage.Headers.Add("X-ClientLocalIP", "");
                  httpRequestMessage.Headers.Add("X-ClientPublicIP", "");
                  httpRequestMessage.Headers.Add("X-MACAddress", "");
                  httpRequestMessage.Headers.Add("X-PrivateKey", tradingAccount?.ApiKey);
      
                  OrderPlaceRequest request = new OrderPlaceRequest();
                  request.TradingSymbol = position.TradingSymbol;
                  request.SymbolToken = position.Token;
                  request.Exchange = position.Exchange.ToString();
                  request.OrderType = position.OrderType.ToString();
                  request.ProductType = position.ProductType.ToString();
                  if (position.TradeSide == Enums.TradeSides.Buy)
                  {
                      request.TransactionType = "BUY";
                  }
                  else
                  {
                      request.TransactionType = "SELL";
                  }
                  request.Price = position.EntryPrice.ToString("N2");
                  request.Quantity = position.EntryQty.ToString("N0");
      
                  httpRequestMessage.Content = JsonContent.Create(request);
      
                  HttpClient httpClient = _httpClientFactory.CreateClient();
                  httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                  HttpResponseMessage httpResponseMessage = await httpClient.SendAsync(httpRequestMessage);
                  if (httpResponseMessage.IsSuccessStatusCode)
                  {
                      string response = await httpResponseMessage.Content.ReadAsStringAsync();
                      if (response.Contains("SUCCESS"))
                      {
                          OrderPlaceResponse? orderPlaceResponse = await httpResponseMessage.Content.ReadFromJsonAsync<OrderPlaceResponse>();
                          if (orderPlaceResponse != null)
                          {
                              if (orderPlaceResponse.Status == true && orderPlaceResponse.Data != null && orderPlaceResponse.Data.Script == position.TradingSymbol)
                              {
                                  position.EntryStatus = Enums.TradeStatus.Open;
                                  position.EntryOrderId = orderPlaceResponse.Data.OrderId;
                                  position.EntryUniqueOrderId = orderPlaceResponse.Data.UniqueOrderId;
                                  result = true;
                              }
                          }
                      }
                      else
                      {
                          ErrorResponse? errorResponse = await httpResponseMessage.Content.ReadFromJsonAsync<ErrorResponse>();
                          if (errorResponse != null)
                          {
                              position.EntryStatus = Enums.TradeStatus.Failed;
                              _loggerService.Error(errorResponse.Message);
                          }
                      }
                  }
                  else
                  {
                      position.EntryStatus = Enums.TradeStatus.Failed;
                      _loggerService.Error("Request failed. Check network connection");
                  }
              }
          }
          catch (Exception ex)
          {
              Trace.WriteLine("Login Error : " + ex.ToString());
          }
      
          return result;
      
      }
      

      And the request captured in webhook.site is given below for more details

      {
        "variety": "NORMAL",
        "tradingSymbol": "NIFTY27FEB2523150CE",
        "symbolToken": "55645",
        "transactionType": "BUY",
        "exchange": "NFO",
        "orderType": "LIMIT",
        "productType": "INTRADAY",
        "duration": "DAY",
        "price": "27.50",
        "squareoff": "0",
        "stoploss": "0",
        "quantity": "75",
        "triggerPrice": "0",
        "trailingStopLoss": "0",
        "disclosedQuantity": "0",
        "orderTag": ""
      }
      

      Screenshot 2025-02-21 210124.png

      posted in Bugs
      R
      Ranjicgnr
    • RE: {"message":"Invalid Product Type","errorcode":"AB1012","status":false,"data":null}

      @admin The api parameters given below

      {
        "variety": "NORMAL",
        "tradingSymbol": "NIFTY27FEB2523150CE",
        "symbolToken": "55645",
        "transactionType": "BUY",
        "exchange": "NFO",
        "orderType": "LIMIT",
        "productType": "INTRADAY",
        "duration": "DAY",
        "price": "27.50",
        "squareoff": "0",
        "stoploss": "0",
        "quantity": "75",
        "triggerPrice": "0",
        "trailingStopLoss": "0",
        "disclosedQuantity": "0",
        "orderTag": ""
      }
      
      posted in Bugs
      R
      Ranjicgnr
    • RE: {"message":"Invalid Product Type","errorcode":"AB1012","status":false,"data":null}

      I am also getting the same error for NIFTY options. I tried MARGIN, INTRADAY, CARRYFORWARD, MIS. But still it gives same error.

      posted in Bugs
      R
      Ranjicgnr